NAME

MooX::Options::Docs::Option - Parameter of the option keywords

VERSION

version 4.001

DESCRIPTION

The keyword option extend the keyword has with specific parameters for the commandline.

OPTION PARAMETERS

doc | documentation

Documentation for the command line option.

long_doc

Documentation for the man page. By default the doc parameter will be used.

See also Man parameters for more examples to build a nice man page.

required

This attribute indicate that the parameter is mandatory. This attribute is not really used by MooX::Options but the error message will be handle by it to display a consistant error message.

format

Format of the params. It is the same as Getopt::Long::Descriptive.

  • i : integer

  • i@: array of integer

  • s : string

  • s@: array of string

  • f : float value

By default, it's a boolean value.

Take a look of available format with Getopt::Long::Descriptive.

You need to understand that everything is explicit here. Check MooX::Options::Docs::Philosophy to understand. So if you use Moose and you attribute has isa = 'Array[Int]'>, that will not implied the format 'i@'.

format json : special format support

The parameter will be treat like a json string.

option 'hash' => (is => 'ro', json => 1);

myTools --hash='{"a":1,"b":2}' # hash = { a => 1, b => 2 }

negativable

It add the negative version for the option.

myTools --verbose    # verbose = 1
myTools --no-verbose # verbose = 0

repeatable

It append the the "format" the array attribute @.

I advice to add a default value to your attribute to always have an array. Otherwise the default value will be an undefined value.

option foo => (is => 'rw', format => 's@', default => sub { [] });

myTools --foo="abc" --foo="def" # foo = ["abc", "def"]

autosplit

For repeatable option, you can add the autosplit feature with your specific parameters.

option test => (is => 'ro', format => 'i@', default => sub {[]}, autosplit => ',');

myTools --test=1 --test=2 # test = (1, 2)
myTools --test=1,2,3      # test = (1, 2, 3)

It will also handle quoted params with the autosplit

option testStr => (is => 'ro', format => 's@', default => sub {[]}, autosplit => ',');

myTools --testStr='a,b,"c,d",e,f' # testStr ("a", "b", "c,d", "e", "f")

short

Long option can also have short version.

option 'verbose' => (is => 'ro', repeatable => 1, short => 'v');

myTools --verbose # verbose = 1
myTools -v        # verbose = 1

order

Specified the order of the attribute. If you want to push some attribute at the end of the list. By default all option has an order set to 0, and the option is sorted by their name.

option 'at_the_end' => (is => 'ro', order => 999);

SEE ALSO

MooX::Options

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/celogeek/MooX-Options/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

celogeek <me@celogeek.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by celogeek <me@celogeek.com>.

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