line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Cli::Router - Routes commands to their implementation |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 DESCRIPTION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
If you want to "register" a new command, do it here. For more information about how an actual implementation should look like |
8
|
|
|
|
|
|
|
please refer to L. |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Wireguard::WGmeta::Cli::Router; |
15
|
1
|
|
|
1
|
|
82875
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
16
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
17
|
1
|
|
|
1
|
|
6
|
use experimental 'signatures'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
18
|
1
|
|
|
1
|
|
637
|
use Wireguard::WGmeta::Cli::Commands::Show; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
19
|
1
|
|
|
1
|
|
465
|
use Wireguard::WGmeta::Cli::Commands::Set; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
20
|
1
|
|
|
1
|
|
460
|
use Wireguard::WGmeta::Cli::Commands::Help; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
32
|
|
21
|
1
|
|
|
1
|
|
480
|
use Wireguard::WGmeta::Cli::Commands::Enable; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
22
|
1
|
|
|
1
|
|
461
|
use Wireguard::WGmeta::Cli::Commands::Disable; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
23
|
1
|
|
|
1
|
|
452
|
use Wireguard::WGmeta::Cli::Commands::Apply; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
24
|
1
|
|
|
1
|
|
468
|
use Wireguard::WGmeta::Cli::Commands::Add; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
25
|
1
|
|
|
1
|
|
448
|
use Wireguard::WGmeta::Cli::Commands::Remove; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
6
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
498
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw(route_command); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = "0.3.2"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 route_command($ref_list_input_args) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Routes the cmd (first argument of C<@ARGV>) to their implementation. The case of the commands to not matter. |
35
|
|
|
|
|
|
|
Any unknown command is forwarded to L. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
To add a new command add this to the C block: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
/^your_cmd$/ && do { |
40
|
|
|
|
|
|
|
Wireguard::WGmeta::Cli::Commands::YourCmd->new(@cmd_args)->entry_point(); |
41
|
|
|
|
|
|
|
last; |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
B |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 1 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
C<$ref_list_input_args> Reference to C<@ARGV>) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
B |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
None |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
5
|
|
|
5
|
1
|
1605
|
sub route_command($ref_list_input_args) { |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
8
|
|
61
|
5
|
|
|
|
|
19
|
my ($cmd,@cmd_args) = @$ref_list_input_args; |
62
|
5
|
50
|
|
|
|
15
|
if (!defined $cmd){ |
63
|
0
|
|
|
|
|
0
|
Wireguard::WGmeta::Cli::Commands::Help->new->entry_point; |
64
|
|
|
|
|
|
|
} |
65
|
5
|
|
|
|
|
13
|
for ($cmd) { |
66
|
5
|
50
|
|
|
|
16
|
/^show$/ && do { |
67
|
0
|
|
|
|
|
0
|
Wireguard::WGmeta::Cli::Commands::Show->new(@cmd_args)->entry_point(); |
68
|
0
|
|
|
|
|
0
|
last; |
69
|
|
|
|
|
|
|
}; |
70
|
5
|
100
|
|
|
|
24
|
/^set$/ && do { |
71
|
3
|
|
|
|
|
33
|
Wireguard::WGmeta::Cli::Commands::Set->new(@cmd_args)->entry_point(); |
72
|
2
|
|
|
|
|
47
|
last; |
73
|
|
|
|
|
|
|
}; |
74
|
2
|
100
|
|
|
|
11
|
/^enable$/ && do { |
75
|
1
|
|
|
|
|
14
|
Wireguard::WGmeta::Cli::Commands::Enable->new(@cmd_args)->entry_point(); |
76
|
1
|
|
|
|
|
26
|
last; |
77
|
|
|
|
|
|
|
}; |
78
|
1
|
50
|
|
|
|
6
|
/^disable$/ && do { |
79
|
1
|
|
|
|
|
15
|
Wireguard::WGmeta::Cli::Commands::Disable->new(@cmd_args)->entry_point(); |
80
|
1
|
|
|
|
|
27
|
last; |
81
|
|
|
|
|
|
|
}; |
82
|
0
|
0
|
|
|
|
|
/^addpeer$/ && do { |
83
|
0
|
|
|
|
|
|
Wireguard::WGmeta::Cli::Commands::Add->new(@cmd_args)->entry_point(); |
84
|
0
|
|
|
|
|
|
last; |
85
|
|
|
|
|
|
|
}; |
86
|
0
|
0
|
|
|
|
|
/^removepeer$/ && do { |
87
|
0
|
|
|
|
|
|
Wireguard::WGmeta::Cli::Commands::Remove->new(@cmd_args)->entry_point(); |
88
|
0
|
|
|
|
|
|
last; |
89
|
|
|
|
|
|
|
}; |
90
|
0
|
0
|
|
|
|
|
/^apply$/ && do { |
91
|
0
|
|
|
|
|
|
Wireguard::WGmeta::Cli::Commands::Apply->new(@cmd_args)->entry_point(); |
92
|
0
|
|
|
|
|
|
last; |
93
|
|
|
|
|
|
|
}; |
94
|
0
|
|
|
|
|
|
Wireguard::WGmeta::Cli::Commands::Help->new->entry_point; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |