line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::new; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
98672
|
use MooseX::App::Command; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
29927
|
use namespace::autoclean; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
26
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
161
|
use IPC::Cmd qw[can_run]; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
131
|
|
7
|
1
|
|
|
1
|
|
13
|
use File::Basename; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
108
|
|
8
|
1
|
|
|
1
|
|
16
|
use Cwd; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
108
|
|
9
|
1
|
|
|
1
|
|
15
|
use File::Path qw(make_path remove_tree); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
112
|
|
10
|
1
|
|
|
1
|
|
552
|
use YAML::XS; |
|
1
|
|
|
|
|
3696
|
|
|
1
|
|
|
|
|
94
|
|
11
|
1
|
|
|
1
|
|
10
|
use File::Spec; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
12
|
1
|
|
|
1
|
|
10
|
use File::Slurp; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3247
|
|
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
|
|
17
|
my ( $self, $cmd, $info ) = @_; |
49
|
2
|
|
|
|
|
15
|
my $buffer = ""; |
50
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
28
|
if ( |
52
|
|
|
|
|
|
|
scalar IPC::Cmd::run( |
53
|
|
|
|
|
|
|
command => $cmd, |
54
|
|
|
|
|
|
|
verbose => 0, |
55
|
|
|
|
|
|
|
buffer => \$buffer |
56
|
|
|
|
|
|
|
) |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
{ |
59
|
2
|
50
|
|
|
|
71670
|
$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
|
|
37
|
my $self = shift; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
29
|
my $project = $self->project; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
###$DB::single=2; |
72
|
1
|
|
|
|
|
25
|
make_path( File::Spec->catdir($self->project , "conf") ); |
73
|
1
|
|
|
|
|
34
|
make_path( File::Spec->catdir($self->project , "script") ); |
74
|
1
|
|
|
|
|
36
|
make_path( File::Spec->catdir($self->project , "data") ); |
75
|
1
|
|
|
|
|
33
|
make_path( File::Spec->catdir($self->project , "hpc-runner") ); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
31
|
chdir $self->project; |
78
|
1
|
|
|
|
|
7
|
$self->gen_project_yml; |
79
|
1
|
|
|
|
|
452
|
$self->gen_gitignore; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
1051
|
$self->log->info( |
82
|
|
|
|
|
|
|
"By default ./data and ./hpcrunner are added to your git ignore."); |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
564
|
$self->log->info("Setup complete!"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub gen_project_yml { |
88
|
1
|
|
|
1
|
|
3
|
my ($self) = @_; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
24
|
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
|
|
|
|
|
243
|
write_file('.project.yml', Dump $hash); |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
683
|
$self->log->info("Project: ".$self->project." Initialized..."); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub gen_gitignore { |
103
|
1
|
|
|
1
|
|
10
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
14
|
$self->execute_command( "git init", |
106
|
|
|
|
|
|
|
"Git repo successfully initialized : " ); |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
1062
|
write_file('.gitignore', "data\nhpc-runner"); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
755
|
$self->execute_command( "git add .gitignore", "Added .gitignore..." ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |