The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Getopt::App::Complete - Add autocompletion to you Getopt::App script

SYNOPSIS

use Getopt::App -complete;

run(
  'h                      # Print help',
  'bash-completion-script # Print autocomplete script',
  sub {
    my ($app, @args) = @_;
    return print generate_completion_script() if $app->{'bash-completion-script'};
    return print extract_usage()              if $app->{h};
  },
);

DESCRIPTION

Getopt::App::Complete contains helper functions for adding autocompletion to your Getopt::App powered script.

This module is currently EXPERIMENTAL.

EXPORTED FUNCTIONS

complete_reply

$int = complete_reply($app_obj);

This function is the default behaviour when "run" in Getopt::App is called with COMP_POINT and COMP_LINE set.

This function will print completion options based on COMP_POINT and COMP_LINE to STDOUT and is aware of subcommands.

generate_completion_script

$str = generate_completion_script();

This function will detect if the bash or zsh shell is in use and return the appropriate initialization commands.

SEE ALSO

Getopt::App