CLI-Driver

 view release on metacpan or  search on metacpan

lib/CLI/Driver/Class.pm  view on Meta::CPAN

package CLI::Driver::Class;

use Modern::Perl;
use Moose;
use namespace::autoclean;
use Kavorka '-all';
use Data::Printer alias => 'pdump';
use CLI::Driver::Option;

with
  'CLI::Driver::CommonRole',
  'CLI::Driver::ArgParserRole';
  
###############################
###### PUBLIC ATTRIBUTES ######
###############################

has name => ( is => 'rw' );

has attr => (
	is      => 'rw',
	isa     => 'ArrayRef[CLI::Driver::Option]',
	default => sub { [] }
);

has 'use_argv_map' => ( is => 'rw', isa => 'Bool' );

############################
###### PUBLIC METHODS ######
############################

method parse (HashRef :$href!) {

	# self->name
	if ( !$href->{name} ) {
		$self->warn("failed to find class name");
		return 0;    # failed
	}
	else {
		$self->name( $href->{name} );
	}

	# self->attr
	my $attr = $self->_parse_attrs( href => $href );
	if ( !$attr ) {
		return 0;    # failed
	}
	else {
		$self->attr($attr);
	}

	return 1;        # success
}

method find_req_attrs (Bool :$hard = 1, 
                       Bool :$soft = 1) {

	my @req;
	my @opts = @{ $self->attr };

	foreach my $opt (@opts) {

		if ( $opt->is_required ) {

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.511 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )