<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Getopt::Long::Complete - A drop-in replacement for Getopt::Long, with
    bash tab completion

VERSION
    This document describes version 0.12 of Getopt::Long::Complete (from
    Perl distribution Getopt-Long-Complete), released on 2014-08-07.

SYNOPSIS
  First example (simple)
    You just replace "use Getopt::Long" with "use Getopt::Long::Complete"
    and your program suddenly supports tab completion. This works for
    most/many programs. For example, below is source code for "delete-user".

     use Getopt::Long::Complete;
     my %opts;
     GetOptions(
         'help|h'     =&gt; sub { ... },
         'on-fail=s'  =&gt; \$opts{on_fail},
         'user=s'     =&gt; \$opts{name},
         'force'      =&gt; \$opts{force},
         'verbose!'   =&gt; \$opts{verbose},
     );

    To activate completion, put your script somewhere in "PATH" and execute
    this in the shell or put it into your bash startup file (e.g.
    "/etc/profile", "/etc/bash.bashrc", "~/.bash_profile", or "~/.bashrc"):

     complete -C delete-user delete-user

    Now, tab completion works:

     % delete-user &lt;tab&gt;
     --force --help --noverbose --no-verbose --on-fail --user --verbose -h
     % delete-user --h&lt;tab&gt;

  Second example (additional completion)
    The previous example only provides completion for option names. To
    provide completion for option values as well as arguments, you need to
    provide more hints. Instead of "GetOptions", use
    "GetOptionsWithCompletion". It's basically the same as "GetOptions" but
    accepts an extra coderef in the first argument. The code will be invoked
    when completion to option value or argument is needed. Example:

     use Getopt::Long::Complete qw(GetOptionsWithCompletion);
     use Complete::Unix qw(complete_user);
     use Complete::Util qw(complete_array_elem);
     my %opts;
     GetOptionsWithCompletion(
         sub {
             my %args  = @_;
             my $word  = $args{word}; # the word to be completed
             my $ospec = $args{ospec};
             if ($ospec &amp;&amp; $ospec eq 'on-fail=s') {
                 return complete_array_elem(words=&gt;[qw/die warn ignore/], word=&gt;$word);
             } elsif ($ospec eq 'user=s') {
                 return complete_user(word=&gt;$word);
             }
             [];
         },
         'help|h'     =&gt; sub { ... },
         'on-fail=s'  =&gt; \$opts{on_fail},
         'user=s'     =&gt; \$opts{name},
         'force'      =&gt; \$opts{force},
         'verbose!'   =&gt; \$opts{verbose},
     );

DESCRIPTION
    This module provides a quick and easy way to add shell tab completion
    feature to your scripts, including scripts already written using the
    venerable Getopt::Long module.

    Currently only bash is supported, but support for other shells can be
    added in the future.

    This module is basically just a thin wrapper for Getopt::Long. Its
    "GetOptions" function just checks for COMP_LINE/COMP_POINT environment
    variable before passing its arguments to Getopt::Long's GetOptions. If
    COMP_LINE is defined, completion reply will be printed to STDOUT and
    then the program will exit. Otherwise, Getopt::Long's GetOptions is
    called.

    To keep completion quick, you should do "GetOptions()" or
    "GetOptionsWithCompletion()" as early as possible in your script.
    Preferably before loading lots of other Perl modules.

    Getopt::Long::Configure('no_ignore_case', 'bundling');

FUNCTIONS
  GetOptions([\%hash, ]@spec)
    Will call Getopt::Long's GetOptions, except when COMP_LINE environment
    variable is defined, in which case will print completion reply to STDOUT
    and exit.

    Note: Will temporarily set Getopt::Long configuration as follow:
    bundling, no_ignore_case. I believe this a sane default.

  GetOptionsWithCompletion(\&amp;completion, [\%hash, ]@spec)
    Just like "GetOptions", except that it accepts an extra first argument
    "\&amp;completion" containing completion routine for completing option
    *values* and arguments. See Synopsis for example.

SEE ALSO
    Complete::Getopt::Long (the backend for this module), "Complete::Bash".

    Other option-processing modules featuring shell tab completion:
    Getopt::Complete.

    Perinci::CmdLine - an alternative way to easily create command-line
    applications with completion feature.

HOMEPAGE
    Please visit the project's homepage at
    &lt;https://metacpan.org/release/Getopt-Long-Complete&gt;.

SOURCE
    Source repository is at
    &lt;https://github.com/sharyanto/perl-Getopt-Long-Complete&gt;.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    &lt;https://rt.cpan.org/Public/Dist/Display.html?Name=Getopt-Long-Complete&gt;

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

AUTHOR
    Steven Haryanto &lt;stevenharyanto@gmail.com&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2014 by Steven Haryanto.

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

</pre></body></html>