line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Command::webpush; |
2
|
1
|
|
|
1
|
|
712637
|
use Mojo::Base 'Mojolicious::Command'; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
249
|
use Mojo::JSON qw(encode_json decode_json); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
4
|
1
|
|
|
1
|
|
818
|
use Crypt::PK::ECC; |
|
1
|
|
|
|
|
18698
|
|
|
1
|
|
|
|
|
619
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my %COMMAND2JSON = ( |
7
|
|
|
|
|
|
|
create => [ 1 ], |
8
|
|
|
|
|
|
|
); |
9
|
|
|
|
|
|
|
my %COMMAND2CB = ( |
10
|
|
|
|
|
|
|
keygen => \&_keygen, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has description => q{Manage your app's web-push}; |
14
|
|
|
|
|
|
|
has usage => sub { shift->extract_usage }; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _keygen { |
17
|
1
|
|
|
1
|
|
15
|
print STDOUT Crypt::PK::ECC->new->generate_key('prime256v1') |
18
|
|
|
|
|
|
|
->export_key_pem('private'); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _promisify { |
22
|
0
|
|
|
0
|
|
0
|
my ($app, $cmd) = @_; |
23
|
|
|
|
|
|
|
sub { |
24
|
0
|
|
|
0
|
|
0
|
my (undef, @args) = @_; |
25
|
0
|
|
|
|
|
0
|
my @res = eval { $app->$cmd(@args) }; |
|
0
|
|
|
|
|
0
|
|
26
|
0
|
0
|
|
|
|
0
|
$@ ? Mojo::Promise->reject($@) : Mojo::Promise->resolve(@res); |
27
|
0
|
|
|
|
|
0
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub run { |
31
|
6
|
|
|
6
|
1
|
28514
|
my ($self, $cmd, @args) = @_; |
32
|
6
|
100
|
|
|
|
33
|
return print STDOUT $self->usage if !$cmd; |
33
|
5
|
100
|
|
|
|
29
|
return $COMMAND2CB{$cmd}->($self, @args) if $COMMAND2CB{$cmd}; |
34
|
4
|
100
|
|
|
|
9
|
$args[$_] = decode_json($args[$_]) for @{ $COMMAND2JSON{$cmd} || [] }; |
|
4
|
|
|
|
|
38
|
|
35
|
4
|
|
|
|
|
299
|
$cmd .= "_p"; |
36
|
|
|
|
|
|
|
$self->app->webpush->$cmd(@args)->then( |
37
|
3
|
|
|
3
|
|
1750
|
sub { print STDOUT encode_json(@_), "\n" }, |
38
|
1
|
|
|
1
|
|
527
|
sub { print STDERR @_, "\n" }, |
39
|
4
|
|
|
|
|
38
|
)->wait; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding utf8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Mojolicious::Command::webpush - Manage your app's web-push |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Usage: APPLICATION webpush COMMAND [OPTIONS] |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
./myapp.pl webpush create |
55
|
|
|
|
|
|
|
./myapp.pl webpush read |
56
|
|
|
|
|
|
|
./myapp.pl webpush delete |
57
|
|
|
|
|
|
|
./myapp.pl webpush keygen > webpush_private_key.pem |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Options: |
60
|
|
|
|
|
|
|
-h, --help Show this summary of available options |
61
|
|
|
|
|
|
|
--home Path to home directory of your application, defaults to |
62
|
|
|
|
|
|
|
the value of MOJO_HOME or auto-detection |
63
|
|
|
|
|
|
|
-m, --mode Operating mode for your application, defaults to the |
64
|
|
|
|
|
|
|
value of MOJO_MODE/PLACK_ENV or "development" |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L manages your application's web-push |
69
|
|
|
|
|
|
|
information. It gives a command-line interface to the relevant helpers |
70
|
|
|
|
|
|
|
in L. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The C command prints a PEM-encoded L |
73
|
|
|
|
|
|
|
C result. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L inherits all attributes from |
78
|
|
|
|
|
|
|
L and implements the following new ones. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L inherits all methods from |
83
|
|
|
|
|
|
|
L and implements the following new ones. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |