App-Easer

 view release on metacpan or  search on metacpan

lib/App/Easer/V1.pod  view on Meta::CPAN

=pod

=for vim
   vim: tw=72 ts=3 sts=3 sw=3 et ai :

=encoding utf8

=head1 NAME

App::Easer::V1 - Simplify writing (hierarchical) CLI applications


=head1 VERSION

This document describes App::Easer::V1 version {{[ version ]}}.

=head1 SYNOPSIS

   #!/usr/bin/env perl
   use v5.24;
   use experimental 'signatures';
   use App::Easer V1 => 'run';
   my $app = {
      commands => {
         MAIN => {
            name => 'main app',
            help => 'this is the main app',
            description => 'Yes, this really is the main app',
            options => [
               {
                  name => 'foo',
                  help => 'option foo!',
                  getopt => 'foo|f=s',
                  environment => 'FOO',
                  default => 'bar',
               },
            ],
            execute => sub ($global, $conf, $args) {
               my $foo = $conf->{foo};
               say "Hello, $foo!";
               return 0;
            },
            'default-child' => '', # run execute by default
         },
      },
   };
   exit run($app, [@ARGV]);

Call examples:

   $ ./example.pl
   Hello, bar!

   $ ./example.pl --foo World
   Hello, World!

   $ ./example.pl commands
   $ perl lib/App/Easer.pm commands
              help: print a help message
          commands: list sub-commands

   $ ./example.pl help
   this is the main app

   Description:
       Yes, this really is the main app

   Options:
               foo: 
                    command-line: mandatory string option
                                  --foo <value>
                                  -f <value>
                    environment : FOO
                    default     : bar

   Sub commands:
              help: print a help message
          commands: list sub-commands

   $ ./example.pl help help
   print a help message

   Description:
       print help for (sub)command

   This command has no options.

   $ ./example.pl help commands
   list sub-commands

   Description:
       Print list of supported sub-commands

   This command has no options.

   $ ./example.pl inexistent
   cannot find sub-command 'inexistent'

   $ ./example.pl help inexistent
   cannot find sub-command 'inexistent'



( run in 1.483 second using v1.01-cache-2.11-cpan-2398b32b56e )