| 1 | package TaskPipe::Tool::Command; | ||||||||||
| 2 | |||||||||||
| 3 | 37 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 37 | ▶ | use DateTime; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 37 | ▶ | use TaskPipe::SchemaManager; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 37 | ▶ | use TaskPipe::JobManager; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 37 | ▶ | use TaskPipe::Tool::Options; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 37 | ▶ | use Pod::Term; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 37 | with 'MooseX::ConfigCascade'; | |||||||||
| 11 | |||||||||||
| 12 | has run_info => (is => 'rw', isa => 'TaskPipe::RunInfo', default => sub{ | ||||||||||
| 13 | 2702 | ▶ | TaskPipe::RunInfo->new; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 37 | }); | |||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | has options => (is => 'rw', isa => 'TaskPipe::Tool::Options', default => sub{ | ||||||||||
| 18 | 2702 | ▶ | TaskPipe::Tool::Options->new; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 37 | }); | |||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | has path_settings => (is => 'ro', isa => 'TaskPipe::PathSettings', default => sub{ | ||||||||||
| 23 | 2702 | ▶ | TaskPipe::PathSettings->new( scope => 'project' ) | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 37 | }); | |||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | has job_manager => (is => 'ro', isa => 'TaskPipe::JobManager', lazy => 1, default => sub{ | ||||||||||
| 28 | 407 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.6
| |||||||||||
| 29 | |||||||||||
| 30 | 407 | my $project = '*global'; | |||||||||
| 31 | 407 | ▶ | if ( $self->run_info->scope eq 'project' ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 407 | $project = $self->path_settings->project_name; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 407 | ▶ | if (! $project ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | confess "[B<Attempted to start a project-related job, but no project name could be determined. Did you forget to include the> C<--project> B<parameter on the command line? Alternatively, specify a default project in the TaskPipe::PathSettings::Global section of your config:> | |||||||||
| 37 | |||||||||||
| 38 | project: myprojectname | ||||||||||
| 39 | |||||||||||
| 40 | ]"; | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | TaskPipe::JobManager->new( | ||||||||||
| 44 | 407 | name => $_[0]->name, | |||||||||
| 45 | project => $project, | ||||||||||
| 46 | shell => 'foreground', | ||||||||||
| 47 | created_dt => DateTime->now | ||||||||||
| 48 | ); | ||||||||||
| 49 | 37 | }); | |||||||||
| 50 | |||||||||||
| 51 | 826 | ▶ | sub name{ my ($n) = ref($_[0]) =~ /^${\__PACKAGE__}_(\w+)$/; $n; } | ||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 52 | |||||||||||
| 53 | =head1 NAME | ||||||||||
| 54 | |||||||||||
| 55 | TaskPipe::Tool::Command - base class for TaskPipe Tool commands | ||||||||||
| 56 | |||||||||||
| 57 | =head1 DESCRIPTION | ||||||||||
| 58 | |||||||||||
| 59 | See individual <TaskPipe::Tool::Command_...> packages for information on specific commands. You should not use this class directly. | ||||||||||
| 60 | |||||||||||
| 61 | You can create a new tool command by inheriting from this class. However, this is not for the faint-hearted and not recommended if you don't fully understand TaskPipe architecture. | ||||||||||
| 62 | |||||||||||
| 63 | The inherited package should look like this: | ||||||||||
| 64 | |||||||||||
| 65 | package TaskPipe::Tool::Command_NewCommand; | ||||||||||
| 66 | use Moose; | ||||||||||
| 67 | extends 'TaskPipe::Tool::Command'; | ||||||||||
| 68 | with 'MooseX::ConfigCascade'; | ||||||||||
| 69 | |||||||||||
| 70 | has option_specs => (is => 'ro', isa => 'ArrayRef', defaults => sub{[ | ||||||||||
| 71 | |||||||||||
| 72 | # which options are available for your command? | ||||||||||
| 73 | # Enter settings attributes like this: | ||||||||||
| 74 | { | ||||||||||
| 75 | module: (name of module to take settings from) | ||||||||||
| 76 | items: [ | ||||||||||
| 77 | # (arrayref of attributes to take from | ||||||||||
| 78 | # the module - or omit to take them all) | ||||||||||
| 79 | ], | ||||||||||
| 80 | is_config: 1 # Boolean. Are the settings taken | ||||||||||
| 81 | from this module available in config | ||||||||||
| 82 | or just on command line? | ||||||||||
| 83 | }, | ||||||||||
| 84 | |||||||||||
| 85 | { | ||||||||||
| 86 | # ... | ||||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | ]}); | ||||||||||
| 90 | |||||||||||
| 91 | sub execute{ | ||||||||||
| 92 | my ($self) = @_; | ||||||||||
| 93 | |||||||||||
| 94 | # execute the command here | ||||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 1; | ||||||||||
| 100 | |||||||||||
| 101 | See the other C<TaskPipe::Tool::Command_> packages for examples of how to prepare a command. | ||||||||||
| 102 | |||||||||||
| 103 | =head1 AUTHOR | ||||||||||
| 104 | |||||||||||
| 105 | Tom Gracey <tomgracey@gmail.com> | ||||||||||
| 106 | |||||||||||
| 107 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 108 | |||||||||||
| 109 | Copyright (c) Tom Gracey 2018 | ||||||||||
| 110 | |||||||||||
| 111 | TaskPipe is free software, licensed under | ||||||||||
| 112 | |||||||||||
| 113 | The GNU Public License Version 3 | ||||||||||
| 114 | |||||||||||
| 115 | =cut | ||||||||||
| 116 | |||||||||||
| 117 | 37 | __PACKAGE__->meta->make_immutable; | |||||||||
| 118 | 37 | 1; | |||||||||