| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Daiku::CLI; |
|
2
|
3
|
|
|
3
|
|
125286
|
use strict; |
|
|
3
|
|
|
|
|
28
|
|
|
|
3
|
|
|
|
|
85
|
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
62
|
|
|
4
|
3
|
|
|
3
|
|
929
|
use Daiku::Daikufile; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
101
|
|
|
5
|
3
|
|
|
3
|
|
2233
|
use Getopt::Long 2.39 (); |
|
|
3
|
|
|
|
|
25117
|
|
|
|
3
|
|
|
|
|
137
|
|
|
6
|
3
|
|
|
3
|
|
1277
|
use Encode qw/encode_utf8/; |
|
|
3
|
|
|
|
|
16153
|
|
|
|
3
|
|
|
|
|
226
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
45
|
use Mouse 0.92; |
|
|
3
|
|
|
|
|
62
|
|
|
|
3
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has file => ( |
|
11
|
|
|
|
|
|
|
is => 'rw', |
|
12
|
|
|
|
|
|
|
isa => 'Str', |
|
13
|
|
|
|
|
|
|
default => "Daikufile", |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub run { |
|
17
|
10
|
|
|
10
|
0
|
19702
|
my ($self, @args) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
10
|
|
|
|
|
118
|
my $p = Getopt::Long::Parser->new( |
|
20
|
|
|
|
|
|
|
config => [qw(posix_default no_ignore_case bundling)], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
10
|
|
|
|
|
1264
|
$p->getoptionsfromarray( |
|
24
|
|
|
|
|
|
|
\@args, |
|
25
|
|
|
|
|
|
|
"f|file=s" => \(my $file), |
|
26
|
|
|
|
|
|
|
"C|directory=s" => \(my $directory), |
|
27
|
|
|
|
|
|
|
"h|help" => \(my $help), |
|
28
|
|
|
|
|
|
|
"v|version" => \(my $version), |
|
29
|
|
|
|
|
|
|
"T|tasks" => \(my $tasks), |
|
30
|
|
|
|
|
|
|
); |
|
31
|
10
|
50
|
|
|
|
3351
|
if ($version) { |
|
32
|
0
|
|
|
|
|
0
|
require Daiku; |
|
33
|
0
|
|
|
|
|
0
|
printf "Daiku %s\n", Daiku->VERSION; |
|
34
|
0
|
|
|
|
|
0
|
exit 0; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
10
|
50
|
|
|
|
24
|
if ($help) { |
|
37
|
0
|
|
|
|
|
0
|
require Pod::Usage; |
|
38
|
0
|
|
|
|
|
0
|
Pod::Usage::pod2usage(0); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
10
|
|
|
|
|
20
|
my @target = @args; |
|
42
|
|
|
|
|
|
|
|
|
43
|
10
|
100
|
|
|
|
40
|
$self->file($file) if $file; |
|
44
|
10
|
100
|
|
|
|
51
|
if ($directory) { |
|
45
|
1
|
50
|
|
|
|
8
|
chdir $directory or die "chdir $directory failed: $!\n"; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
10
|
|
|
|
|
120
|
my $engine = Daiku::Daikufile->parse($self->file); |
|
49
|
|
|
|
|
|
|
|
|
50
|
9
|
100
|
|
|
|
25
|
if ($tasks) { |
|
51
|
1
|
|
|
|
|
6
|
_print_tasks($engine->tasks); |
|
52
|
1
|
|
|
|
|
20
|
return 0; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
8
|
100
|
|
|
|
22
|
if (!@target) { |
|
56
|
2
|
|
|
|
|
5
|
@target = ('default'); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
13
|
my $exit = 0; |
|
60
|
8
|
|
|
|
|
16
|
for my $target (@target) { |
|
61
|
10
|
|
|
|
|
12
|
eval { $engine->build($target) }; |
|
|
10
|
|
|
|
|
34
|
|
|
62
|
10
|
100
|
|
|
|
35
|
if ($@) { |
|
63
|
4
|
|
|
|
|
200
|
warn "$@\n"; |
|
64
|
4
|
|
|
|
|
17
|
$exit = 2; # like make(1) |
|
65
|
4
|
|
|
|
|
7
|
last; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
8
|
|
|
|
|
85
|
return $exit; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _print_tasks { |
|
72
|
1
|
|
|
1
|
|
1
|
my $tasks = shift; |
|
73
|
1
|
|
|
|
|
2
|
my $column_width = 1; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
1
|
my @tasks; |
|
76
|
1
|
|
|
|
|
3
|
for my $task (values %$tasks) { |
|
77
|
6
|
100
|
100
|
|
|
64
|
next unless $task->isa('Daiku::Task') && defined $task->desc; |
|
78
|
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
50
|
my $task_name = $task->dst; |
|
80
|
3
|
|
|
|
|
5
|
my $len = length $task_name; |
|
81
|
3
|
100
|
|
|
|
6
|
$column_width = $len if $column_width < $len; |
|
82
|
3
|
|
|
|
|
16
|
push @tasks, { |
|
83
|
|
|
|
|
|
|
name => $task_name, |
|
84
|
|
|
|
|
|
|
desc => $task->desc, |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
7
|
for my $t (@tasks) { |
|
89
|
3
|
|
|
|
|
75
|
printf "daiku %-${column_width}s # %s\n", encode_utf8($t->{name}), encode_utf8($t->{desc}); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
3
|
|
|
3
|
|
2082
|
no Mouse; __PACKAGE__->meta->make_immutable; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
12
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |