App::Yath::Options(3pm) | User Contributed Perl Documentation | App::Yath::Options(3pm) |
App::Yath::Options - Tools for defining and tracking yath CLI options.
This class represents a collection of options, and holds the logic for processing them. This package also exports sugar to help you define options.
package My::Options; use App::Yath::Options; # This package now has a package instance of options, which can be obtained # via the options() method. my $options = __PACKAGE__->options; # We can include options from other packages include_options( 'Package::With::Options::A', 'Package::With::Options::B', ..., ); # Define an option group with some options option_group { %common_fields } => sub { # Define an option option foo => ( type => 's', default => "FOOOOOOO", category => 'foo', description => "This is foo" long_examples => [' value'], ... ); option bar => ( ... ); ... }; # Action to call right after options are parsed. post sub { my %params = @_; ... };
These are both equivalent:
# Using option group option_group { category => 'foo', prefix => 'foo' } => sub { option a => (type => 'b'); option b => (type => 's'); }; # Not using option group option a => (type => 'b', category => 'foo', prefix => 'foo'); option b => (type => 's', category => 'foo', prefix => 'foo');
If no $weight is specified then 0 is used. "post" callbacks or sorted based on weight with higher values being run later.
In general you should not be using the options instance directly. Options instances are mostly an implementation detail that should be treated as a black box. There are however a few valid reasons to interact with them directly. In those cases there are a few public attributes/methods you can work with. This section documents the public interface.
This section only lists attributes that may be useful to people working with options instances. There are a lot of internal (to yath) attributes that are implementation details that are not listed here. Attributes not listed here are not intended for external use and may change at any time.
This section only lists methods that may be useful to people working with options instances. There are a lot of internal (to yath) methods that are implementation details that are not listed here. Methods not listed here are not intended for external use and may change at any time.
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/.
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
2023-03-12 | perl v5.36.0 |