NAME

App::Spec - Specification for commandline apps

SYNOPSIS

WARNING: This is still experimental. The spec is subject to change.

This module represents a specification of a command line tool. Currently it can read the spec from a YAML file or directly from a data structure in perl.

The App::Spec::Run module is the framework which will run the actual app.

In the examples directory you will find the app myapp which is supposed to demonstrate everything that App::Spec supports right now.

Your script:

use App::Spec;
my $spec = App::Spec->read("/path/to/myapp-spec.yaml");

my $run = $spec->runner;
$run->run;

# this is equivalent to
#my $run = Your::App->new({
#    spec => $spec,
#});
#$run->run;

Your App class:

package Your::App;
use base 'App::Spec::Run';

sub command1 {
    my ($self) = @_;
    my $options = $self->options;
    my $param = $self->parameters;
    # Do something
}

METHODS

read
my $spec = App::Spec->read("/path/to/myapp-spec.yaml");
runner

Returns an instance of the your app class

my $run = $spec->runner;
$run->run;

# this is equivalent to
my $run = App::Spec::Example::MyApp->new({
    spec => $spec,
});
$run->run;
usage

Returns usage output for the specified subcommands:

my $usage = $spec->usage(
    commands => ["subcommand1","subcommand2"],
);
generate_completion

Generates shell completion script for the spec.

my $completion = $spec->generate_completion(
    shell => "zsh",
);
generate_pod
my $pod = $spec->generate_pod;
make_getopt

Returns options for Getopt::Long

my @getopt = $spec->make_getopt($global_options, \%options, $option_specs);
abstract, appspec, class, description, has_subcommands, markup, name, options, parameters, subcommands, title

Accessors for the things defined in the spec (file)

SEE ALSO

App::AppSpec - Utilities for App::Spec authors