Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

prophet::cli(3pm) [debian man page]

Prophet::CLI(3pm)					User Contributed Perl Documentation					 Prophet::CLI(3pm)

   _record_cmd
       handles the subcommand for a particular type

   dispatcher_class -> Class
       Returns class name of the dispatcher used to dispatch command lines.  By default app_class::CLI::Dispatcher is used if it can be loaded
       otherwise Prophet::CLI::Dispatcher. Override using:

	   has '+dispatcher_class' => ( default => 'MyApp::Dispatcher' );

   run_one_command
       Runs a command specified by commandline arguments given in an ARGV-like array of argumnents and key value pairs . To use in a commandline
       front-end, create a Prophet::CLI object and pass in your main app class as app_class, then run this routine.

       Example:

	my $cli = Prophet::CLI->new({ app_class => 'App::SD' });
	$cli->run_one_command(@ARGV);

   get_script_name
       Return the name of the script that was run. This is the empty string if we're in a shell, otherwise the script name concatenated with a
       space character. This is so you can just use this for e.g.  printing usage messages or help docs that might be run from either a shell or
       the command line.

perl v5.10.1							    2009-12-22							 Prophet::CLI(3pm)

Check Out this Related Man Page

App::CLI(3)						User Contributed Perl Documentation					       App::CLI(3)

NAME
App::CLI - Dispatcher module for command line interface programs SYNOPSIS
package MyApp; use base 'App::CLI'; # the DISPATCHER of your App # it's not necessary putting the dispather # on the top level of your App package main; MyApp->dispatch; # call dispather in where you want package MyApp::List; use base qw(App::CLI::Command); # any (SUB)COMMAND of your App use constant options => qw( "h|help" => "help", "verbose" => "verbose", 'n|name=s' => 'name', ); use constant subcommands => qw(User Nickname type); # if you want subcommands # automatically dispatch to subcommands # when invoke $ myapp list [user|nickname|--type] # note 'type' lower case in first char # is subcommand of old genre which is deprecated sub run { my ($self, @args) = @_; print "verbose" if $self->{verbose}; my $name = $self->{name}; # get arg following long option --name if ($self->{help}) { # if $ myapp list --help or $ $ myapp list -h # just only output PODs } else { # do something when imvoking $ my app list # without subcommand and --help } } package MyApp::List::User; use base qw(App::CLI::Command); use constant options => ( "h|help" => "help", ); sub run { my ($self,@args) = @_; # code for listing user } pakcage MyApp::List::Nickname; use base qw(App::CLI::Command); use constant options => ( "sort=s" => "sort", ); sub run { my ($self,@args) = @_; # code for listing nickname } package MyApp::List::type; # old genre of subcommand could not be cascading infinitely use base qw(MyApp::List); # should inherit its parents command sub run { my ($self, @args); # run to here when invoking $ myapp list --type } package MyApp::Help; use base 'App::CLI::Command::Help'; use constant options => ( 'verbose' => 'verbose', ); sub run { my ($self, @arg) = @_; # do something $self->SUPER(@_); # App::CLI::Command::Help would output PDOs of each command } DESCRIPTION
"App::CLI" dispatches CLI (command line interface) based commands into command classes. It also supports subcommand and per-command options. get_opt([@config], %opt_map) give options map, process by Getopt::Long::Parser interface of dispatcher cmd_map($cmd) find package name of subcommand in constant %alias if it's finded, return ucfirst of the package name, otherwise, return ucfirst of $cmd itself. get_cmd($cmd, @arg) return subcommand of first level via $ARGV[0] SEE ALSO
App::CLI::Command Getopt::Long AUTHORS
Chia-liang Kao <clkao@clkao.org> Cornelius Lin <cornelius.howl@gmail.com> shelling <navyblueshellingford@gmail.com> COPYRIGHT
Copyright 2005-2006 by Chia-liang Kao <clkao@clkao.org>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> perl v5.16.2 2010-12-04 App::CLI(3)
Man Page