Getopt::Complete::Compgen - standard tab-completion callbacks


Back to Top


NAME

Getopt::Complete::Compgen - standard tab-completion callbacks

Back to Top


VERSION

This document describes Getopt::Complete::Compgen 0.25.

Back to Top


SYNOPSIS

 # A completion spec can use any of the following, specified by a single
 # word, or a single character, automatically:
 
 use Getopt::Complete(
    'myfile'    => 'files',         # or 'f'
    'mydir'     => 'directories',   # or 'd'
    'mycommand' => 'commands',      # or 'c'
    'myuser'    => 'users',         # or 'u'
    'mygroup'   => 'groups',        # or 'd'
    'myenv'     => 'environment',   # or 'e'
    'myservice' => 'services',      # or 's'
    'myalias'   => 'aliases',       # or 'a'
    'mybuiltin' => 'builtins'       # or 'b'
 );

Back to Top


DESCRIPTION

This module contains subroutines which can be used as callbacks with Getopt::Complete, and which implement all of the standard completions supported by the bash "compgen" builtin.

Running "compgen -o files abc" will produce the completion list as though the user typed "abc<TAB>", with the presumption the user is attempting to complete file names.

This module provides a subroutine names "files", with an alias named "f", which returns the same list.

The subroutine is suitable for use in a callback in a Getopt::Complete competion specification.

It does the equivalent for directories, executable commands, users, groups, environment variables, services, aliases and shell builtins.

These are the same:

 @matches = Getopt::Complete::Compgen::files("whatevercommand","abc","whateverparam",$whatever_other_args);
 
 @same = `bash -c "compgen -f sometext"`;
 chomp @same;

These are equivalent in any spec:

   \&Getopt::Complete::Compgen::files
   \&Getopt;:Complete::Compgen::f
     'Getopt::Complete::Compgen::files'
     'Getopt;:Complete::Compgen::f'
     'files'
     'f'

Back to Top


SEE ALSO

the Getopt::Complete manpage

The manual page for bash details the bash built-in command "compgen", which this wraps.

Back to Top


COPYRIGHT

Copyright 2010 Scott Smith and Washington University School of Medicine

Back to Top


AUTHORS

Scott Smith (sakoht at cpan .org)

Back to Top


LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

Back to Top

 Getopt::Complete::Compgen - standard tab-completion callbacks