line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::new; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
59496
|
use MooseX::App::Command; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
18
|
|
4
|
1
|
|
|
1
|
|
12762
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
89
|
use IPC::Cmd qw[can_run]; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
74
|
|
7
|
1
|
|
|
1
|
|
7
|
use File::Basename; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
60
|
|
8
|
1
|
|
|
1
|
|
7
|
use Cwd; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
56
|
|
9
|
1
|
|
|
1
|
|
7
|
use File::Path qw(make_path remove_tree); |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
83
|
|
10
|
1
|
|
|
1
|
|
374
|
use YAML::XS; |
|
1
|
|
|
|
|
2079
|
|
|
1
|
|
|
|
|
49
|
|
11
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
12
|
1
|
|
|
1
|
|
7
|
use File::Slurp; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
422
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'HPC::Runner::Command'; |
15
|
|
|
|
|
|
|
with 'MooseX::App::Role::Log4perl'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
command_short_description 'Create a new project'; |
18
|
|
|
|
|
|
|
command_long_description |
19
|
|
|
|
|
|
|
'This creates a new project, initializes git and directory structure.'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 HPC::Runner::Command::new |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Create a new project using |
24
|
|
|
|
|
|
|
hpcrunner.pl new |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 Command Line Options |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
option 'project' => ( |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
isa => 'Str', |
33
|
|
|
|
|
|
|
documentation => 'Project name for your analysis project.', |
34
|
|
|
|
|
|
|
required => 1, |
35
|
|
|
|
|
|
|
predicate => 'has_project', |
36
|
|
|
|
|
|
|
cmd_aliases => ['p'], |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 Subroutines |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head3 execute_command |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Execute short commands |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub execute_command { |
48
|
2
|
|
|
2
|
|
9
|
my ( $self, $cmd, $info ) = @_; |
49
|
2
|
|
|
|
|
5
|
my $buffer = ""; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
16
|
if ( |
52
|
|
|
|
|
|
|
scalar IPC::Cmd::run( |
53
|
|
|
|
|
|
|
command => $cmd, |
54
|
|
|
|
|
|
|
verbose => 0, |
55
|
|
|
|
|
|
|
buffer => \$buffer |
56
|
|
|
|
|
|
|
) |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
{ |
59
|
2
|
50
|
|
|
|
42261
|
$self->log->info("$info: $buffer\n") if $info; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
0
|
|
|
|
|
0
|
$self->log->warn("Something went wrong with the cmd: $cmd!\n"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub execute { |
67
|
1
|
|
|
1
|
|
23
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
27
|
my $project = $self->project; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
###$DB::single=2; |
72
|
1
|
|
|
|
|
24
|
make_path( File::Spec->catdir($self->project , "conf") ); |
73
|
1
|
|
|
|
|
35
|
make_path( File::Spec->catdir($self->project , "script") ); |
74
|
1
|
|
|
|
|
34
|
make_path( File::Spec->catdir($self->project , "data") ); |
75
|
1
|
|
|
|
|
33
|
make_path( File::Spec->catdir($self->project , "hpc-runner") ); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
34
|
chdir $self->project; |
78
|
1
|
|
|
|
|
7
|
$self->gen_project_yml; |
79
|
1
|
|
|
|
|
285
|
$self->gen_gitignore; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
388
|
$self->log->info( |
82
|
|
|
|
|
|
|
"By default ./data and ./hpcrunner are added to your git ignore."); |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
292
|
$self->log->info("Setup complete!"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub gen_project_yml { |
88
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
25
|
my $hash = { |
91
|
|
|
|
|
|
|
ProjectName => $self->project, |
92
|
|
|
|
|
|
|
TopDir => getcwd(), |
93
|
|
|
|
|
|
|
LogDir => File::Spec->catdir(cwd() , "hpc-runner", "logs"), |
94
|
|
|
|
|
|
|
BlogDir => File::Spec->catdir(cwd() , "hpc-runner", "www", "hexo") |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
149
|
write_file('.project.yml', Dump $hash); |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
386
|
$self->log->info("Project: ".$self->project." Initialized..."); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub gen_gitignore { |
103
|
1
|
|
|
1
|
|
6
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
9
|
$self->execute_command( "git init", |
106
|
|
|
|
|
|
|
"Git repo successfully initialized : " ); |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
383
|
write_file('.gitignore', "data\nhpc-runner"); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
276
|
$self->execute_command( "git add .gitignore", "Added .gitignore..." ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |