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); # if you want subcommands

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 {
        if ($self->cascadable) {
            $self->cascading->run_command; # if you want to invoke MyApp::List::User or MyApp::List::Nickname
        } else {
            # do something that without subcommand
            # or die as below
            $self->error_cmd;
        }
    }
}

package MyApp::List::User;
use base qw(App::CLI::Command);

sub run {
    my ($self,@args) = @_;
    # code for listing user
}

pakcage MyApp::List::Nickname;
use base qw(App::CLI::Command);

sub run {
    my ($self,@args) = @_;
    # code for listing nickname
}


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.

TODO

More documentation

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