NAME

Getopt::Mini

VERSION

version 0.03

SYNOPSIS

use Getopt::Mini;
say $ARGV{'flag'};

DESCRIPTION

This is, yup, yet another Getopt module, a very lightweight one. It's not declarative in any way, ie, it does not support specs, like Getopt::Long et al do.

On the other hand, it can validate your parameters using the Data::Validator syntax. But that's a hidden feature for now (you'll need to install Data::Validator yourself and find a way to run it by reading this source code).

NAME

Getopt::Mini

VERSION

version 0.02

NAME

Getopt::Mini - yet another yet-another Getopt module

VERSION

version 0.02

USAGE

The rules:

* -<char>
    does not consume barewords (ie. -f, -h, ...)
    unless you set hungry_flags=>1

* -<str> <bareword>
* --<str> <bareword>
    will eat up the next bare word (-type f, --file f.txt)

* -<char|str>=<val> and --<str>=<val>
    consumes its value and nothing more

* <str>
    gets pushed into an array in $ARGV{''}

Some code examples:

perl myprog.pl -h -file foo --file bar
use Getopt::Mini;   # parses the @ARGV into %ARGV
say YAML::Dump \%ARGV;
---
h: 1
file:
  - foo
  - bar

# single flags like -h are checked with exists:

say 'help...' if exists $ARGV{'h'};

# barewords are pushed into the key '_'

perl myprog.pl file1.c file2.c
say "file: $_" for @{ $ARGV{''} };

Or you can just use a modular version:

use Getopt::Mini later=>1; # nothing happens

getopt;   #  imports into %ARGV
my %argv = getopt;   #  imports into %argv instead

array mode

There's also a special mode that can be set with array = 1> that will make a flag consume all following barewords:

perl myprog.pl -a -b --files f1.txt f2.txt
use Getopt::Mini array => 1;
say YAML::Dump \%ARGV;
---
h: ~
file:
  - foo
  - bar

BUGS

This is *ALPHA* software. And despite its small footprint, this is lurking with nasty bugs and potential api changes.

Complaints should be filed to the Getopt Foundation, which has been treating severe NIH syndrome since 1980.

SEE ALSO

Getopt::Whatever - no declarative spec like this module, but the options in %ARGV and @ARGV are not where I expect them to be.

Getopt::Casual - similar to this module, but very keen on turning entries into single param options.

AUTHOR

Rodrigo de Oliveira <rodrigolive@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Rodrigo de Oliveira.

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

AUTHOR

Rodrigo de Oliveira <rodrigolive@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Rodrigo de Oliveira.

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