NAME

App::CLI::Extension - for App::CLI extension module

VERSION

0.01

SYNOPSIS

# YourApp.pm
package YourApp;

use strict;
use base qw(App::CLI::Extension);

# extension method
# load App::CLI::Plugin::Foo,  YourApp::Plugin::Bar
__PACKAGE__->load_plugins(qw(Foo +YourApp::Plugin::Bar));

# extension method
__PACKAGE__->config( name => "kurt");

1;

# YourApp/Hello.pm
package YourApp:Hello;

use strict;
use base qw(App::CLI::Command);
use constant options => ("age=i" => "age");

sub run {

    my($self, @args) = @_;
    # config - App::CLI::Extension extension method(App::CLI::Extension::Component::Config)
    print "Hello! my name is " . $self->config->{name} . "\n";
    print "age is " . "$self->{age}\n";
}

# yourapp
#!/usr/bin/perl

use strict;
use YourApp;

YourApp->dispatch;

# execute
[kurt@localhost ~] youapp hello --age=27
Hello! my name is kurt
age is 27

DESCRIPTION

The expansion module which added plug in, initial setting mechanism to App::CLI

App::CLI::Extension::Component::** modules is automatic, and it is done require

(It is now App::CLI::Extension::Component::Config is automatic, and it is done require)

METHOD

load_plugins

load and require plugins

Example

# YourApp.pm
# YourApp::Plugin::GoodMorning and App::CLI::Plugin::Config::YAML::Syck require
__PACKAGE__->load_plugins(qw(+YourApp::Plugin::GoodMorning Config::YAML::Syck));

# Your/App/Plugin/GoodMorning.pm
package YourApp::Plugin::GoodMorning;

use strict;

sub good_morning {

    my $self = shift;
    print "Good monring!\n";
}

# YourApp/Hello.pm
package YourApp:Hello;

use strict;
use base qw(App::CLI::Command);

sub run {

    my($self, @args) = @_;
    $self->good_morning;
}

# yourapp
#!/usr/bin/perl

use strict;
use YourApp;

YourApp->dispatch;

# execute
[kurt@localhost ~] youapp hello
Good morning!

config

configuration method

Example

# YourApp.pm
__PACKAGE__->config(
               name           => "kurt",
               favorite_group => "nirvana",
               favorite_song  => ["Lounge Act", "Negative Creep", "Radio Friendly Unit Shifter", "You Know You're Right"]
            );

# YourApp/Hello.pm
package YourApp:Hello;

use strict;
use base qw(App::CLI::Command);

sub run {

    my($self, @args) = @_;
    print "My name is " . $self->config->{name} . "\n";
    print "My favorite group is " . $self->config->{favorite_group} . "\n";
    print "My favorite song is " . join(",", @{$self->config->{favorite_song}});
    print " and Smells Like Teen Spirit\n"
}

# yourapp
#!/usr/bin/perl

use strict;
use YourApp;

YourApp->dispatch;

# execute
[kurt@localhost ~] youapp hello
My name is kurt
My favorite group is nirvana
My favorite song is Lounge Act,Negative Creep,Radio Friendly Unit Shifter,You Know You're Right and Smells Like Teen Spirit

SEE ALSO

App::CLI App::CLI::Extension::Component::Config Class::Data::Inheritable Module::Pluggable::Object UNIVERSAL::require

AUTHOR

Akira Horimoto

COPYRIGHT AND LICENSE

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

Copyright (C) 2008 Akira Horimoto