App-Chained

 view release on metacpan or  search on metacpan

example/test_wrapper.pl  view on Meta::CPAN

				run =>
					sub
					{
					my ($self, $command, $arguments) =  @_ ;
					$command->{_MODULE_RUNNER}($self, $command, $arguments) ;
					},
					
				help =>
					sub
					{
					my ($self, $command, $arguments) =  @_ ;
					$command->{_MODULE_RUNNER}($self, $command, ['--help']) ;
					},
					
				options =>
					sub
					{
					my ($self, $command, $arguments) =  @_ ;
					
					use Capture::Tiny qw(capture);
					
					my $runner = $command->{_MODULE_RUNNER} ;
					my ($stdout, $stderr) = 	capture { $runner->($self, $command, ['--dump_options']) };

					return split /\n/, $stdout ;
					},
				},
				
			# code example for code contained in an executable
			test_application =>
				{
				description => 'executable',
				run =>
					sub
					{
					my ($self, $command, $arguments) =  @_ ;
					system './test_application ' . join(' ', @{$arguments}) ;
					},
					
				help => sub {system "./test_application --help"},
				apropos => [qw(executable)],
				#~ options => sub{ ... },
				},
			},
			
		@setup_data,
		) ;

bless $chained_app, $class ;

$chained_app->parse_command_line() ;

# pass option  A and B to our sub command
#~ push @{$chained_app->{command_options}}, ('--A' => $options{A} ) if defined $options{A} ;
#~ push @{$chained_app->{command_options}}, ('--B_changed_to_X' => $options{B} ) if defined $options{B} ;

#~ use Data::TreeDumper ;
#~ print DumpTree $chained_app->{command_options}, 'options' ;

# run the command if we so want
$chained_app->SUPER::run() ;
}

#---------------------------------------------------------------------------------

package main ;

App::Chained::Test->run(command_line_arguments => \@ARGV) ;



( run in 1.059 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )