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 auto-completion to you Getopt::App script

SYNOPSIS

  use Getopt::App -complete;

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

DESCRIPTION

Getopt::App::Complete contains helper functions for adding auto-completion 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