Getopt-Tree

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

  Complex example
     my $p = [
         # Required global parameter.
         { name => 'user', leaf => 1, eval => sub { my ( $p ) = @_; return 1 if $p =~ /^[a-z]+$/i; },
         # Optional global parameter.
         {
             name     => 'no-cache',
             abbr     => 'nc',
             exists   => 1,
             optional => 1,
             descr    => 'Don\'t cache your credentials in /tmp/.'
         },
         # Start of a branch. If one or more branches exist, at least one must be
         # followed.
         {
             name   => 'search',
             abbr   => 's',
             descr  => 'Search for ticket, list tickets in queue, or print contents of a ticket.',
             params => [
                {
                     name   => 'ticket', # field name

lib/Getopt/Tree.pm  view on Meta::CPAN


 my $p = [
     # Required global parameter.
     { name => 'user', leaf => 1, eval => sub { my ( $p ) = @_; return 1 if $p =~ /^[a-z]+$/i; },
     # Optional global parameter.
     {
         name     => 'no-cache',
         abbr     => 'nc',
         exists   => 1,
         optional => 1,
         descr    => 'Don\'t cache your credentials in /tmp/.'
     },
     # Start of a branch. If one or more branches exist, at least one must be
     # followed.
     {
         name   => 'search',
         abbr   => 's',
         descr  => 'Search for ticket, list tickets in queue, or print contents of a ticket.',
         params => [
            {
                 name   => 'ticket', # field name

t/Getopt-Tree.t  view on Meta::CPAN

            name     => 'user',
            abbr     => 'u',
            optional => 1,
            descr    => 'Ticketing username, defaults to scalar(getpwuid($<)).'
        },
        {
            name     => 'no-cache',
            abbr     => 'nc',
            exists   => 1,
            optional => 1,
            descr    => 'Don\'t cache your credentials in /tmp/.'
        },
        {
            name     => 'qa',
            exists   => 1,
            optional => 1,
            descr    => 'Connect to the test system instead of the prod system.'
        },
        {
            name     => 'help',
            abbr     => 'h',



( run in 0.248 second using v1.01-cache-2.11-cpan-4d50c553e7e )