Aion-Run

 view release on metacpan or  search on metacpan

lib/Aion/Run/RunsRun.pm  view on Meta::CPAN

has mask => (is => "ro", isa => Maybe[Str], arg => 1);

#@run run:runs „List of scripts”
sub list {
	my ($self) = @_;

	my @runs = sort {
		$a->{rubric} eq $b->{rubric}? ($a->{name} cmp $b->{name}): $a->{rubric} cmp $b->{rubric}
	} grep { $_->{name} =~ $self->mask } values %{ Aion::Run::Runner->new->runs };
	
	my $len = max map length $_->{name}, @runs;

	for my $run (@runs) {
		eval "require $run->{pkg}";
		my $FEATURE = $Aion::META{$run->{pkg}}{feature};
		my $ARG = {};
		exists $_->{arg} and $ARG->{$_->{arg}} = $_ for values %$FEATURE;

		my @features = sort { $a->{arg} =~ /^\d+$/ && $b->{arg} =~ /^\d+$/ ? $a->{arg} <=> $b->{arg}: $a->{arg} cmp $b->{arg} } values %$ARG;

		$run->{args} = join " ", map {
			my $argument = $_->{opt}{init_arg} // $_->{name};
			my $x = $_->{arg} =~ /^\d+$/ ? $argument :
				$_->{isa}{name} eq "Bool" ? $_->{arg} : "$_->{arg} $argument";
			
			$_->{required} ? ($_->{isa}{name} eq "ArrayRef" ? "$x..." : $x) :
			    ($_->{isa}{name} eq "ArrayRef" ? "[$x...]" : "[$x]")
	    } @features;
	}
	
	my $len2 = max map length $_->{args}, @runs;
	
	my $rubric;
	for(@runs) {
		printcolor "#yellow%s#r\n", $rubric = $_->{rubric} if $rubric ne $_->{rubric};

		printcolor "  #green%-${len}s #{bold red}%-${len2}s #{bold black}%s#r\n", $_->{name}, $_->{args}, $_->{remark};
	}
}

1;

t/aion/run.t  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# # NAME
# 
# Aion::Run - роль для консольных команд
# 
# # VERSION
# 
# 0.0.2
# 
# # SYNOPSIS
# 

t/aion/run/run-run.t  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# # NAME
# 
# Aion::Run::RunRun - выполняет Perl-код и распечатывает результат на STDOUT
# 
# # SYNOPSIS
# 
subtest 'SYNOPSIS' => sub { 
use Aion::Format qw/trappout np/;
use Aion::Run::RunRun;

t/aion/run/runner.t  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# # NAME
# 
# Aion::Run::Runner - запускает команду описанную аннотацией `#@run`
# 
# # SYNOPSIS
# 
# Файл etc/annotation/run.ann:
#@> etc/annotation/run.ann
#>> Aion::Run::RunRun#run,3=run:run „Executes Perl code in the context of the current project”
#>> Aion::Run::RunsRun#list,5=run:runs „List of scripts”

t/aion/run/runs-run.t  view on Meta::CPAN

use common::sense; use open qw/:std :utf8/;  use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//;  use Test::More 0.98;  use String::Diff q...
# # NAME
# 
# Aion::Run::RunsRun - список скриптов с аннотацией `#@run`
# 
# # SYNOPSIS
# 
# Файл etc/annotation/run.ann:
#@> etc/annotation/run.ann
#>> Aion::Run::RunRun#run,3=run:run „Executes Perl code in the context of the current project”
#>> Aion::Run::RunsRun#list,5=run:runs „List of scripts”



( run in 0.581 second using v1.01-cache-2.11-cpan-140bd7fdf52 )