| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ************************************************************************* |
|
2
|
|
|
|
|
|
|
# Copyright (c) 2014-2016, SUSE LLC |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# All rights reserved. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
|
7
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions are met: |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, |
|
10
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright |
|
13
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
|
14
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# 3. Neither the name of SUSE LLC nor the names of its contributors may be |
|
17
|
|
|
|
|
|
|
# used to endorse or promote products derived from this software without |
|
18
|
|
|
|
|
|
|
# specific prior written permission. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
21
|
|
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
22
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
23
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
24
|
|
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
25
|
|
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
26
|
|
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
27
|
|
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
28
|
|
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
29
|
|
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
30
|
|
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE. |
|
31
|
|
|
|
|
|
|
# ************************************************************************* |
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
# Miscellaneous commands |
|
34
|
|
|
|
|
|
|
package App::Dochazka::CLI::Commands::Misc; |
|
35
|
|
|
|
|
|
|
|
|
36
|
20
|
|
|
20
|
|
348
|
use 5.012; |
|
|
20
|
|
|
|
|
64
|
|
|
37
|
20
|
|
|
20
|
|
106
|
use strict; |
|
|
20
|
|
|
|
|
42
|
|
|
|
20
|
|
|
|
|
438
|
|
|
38
|
20
|
|
|
20
|
|
95
|
use warnings; |
|
|
20
|
|
|
|
|
71
|
|
|
|
20
|
|
|
|
|
572
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
20
|
|
|
20
|
|
104
|
use App::CELL qw( $CELL ); |
|
|
20
|
|
|
|
|
48
|
|
|
|
20
|
|
|
|
|
1710
|
|
|
41
|
20
|
|
|
20
|
|
169
|
use App::Dochazka::CLI qw( $debug_mode $prompt_date ); |
|
|
20
|
|
|
|
|
41
|
|
|
|
20
|
|
|
|
|
1566
|
|
|
42
|
20
|
|
|
20
|
|
124
|
use App::Dochazka::CLI::Util qw( init_prompt normalize_date parse_test rest_error ); |
|
|
20
|
|
|
|
|
43
|
|
|
|
20
|
|
|
|
|
1037
|
|
|
43
|
20
|
|
|
20
|
|
114
|
use Data::Dumper; |
|
|
20
|
|
|
|
|
44
|
|
|
|
20
|
|
|
|
|
890
|
|
|
44
|
20
|
|
|
20
|
|
104
|
use Exporter 'import'; |
|
|
20
|
|
|
|
|
40
|
|
|
|
20
|
|
|
|
|
551
|
|
|
45
|
20
|
|
|
20
|
|
90
|
use Web::MREST::CLI qw( send_req ); |
|
|
20
|
|
|
|
|
45
|
|
|
|
20
|
|
|
|
|
4554
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
App::Dochazka::CLI::Commands::Misc - Misc commands |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 PACKAGE VARIABLES |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
62
|
|
|
|
|
|
|
change_prompt_date |
|
63
|
|
|
|
|
|
|
noop |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The functions in this module are called from the parser when it recognizes a command. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 change_prompt_date |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
PROMPT _DATE |
|
78
|
|
|
|
|
|
|
PROMPT DATE _DATE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub change_prompt_date { |
|
83
|
0
|
0
|
|
0
|
1
|
|
print "Entering " . __PACKAGE__ . "::change_prompt_date\n" if $debug_mode; |
|
84
|
0
|
|
|
|
|
|
my ( $ts, $th ) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# parse test |
|
87
|
0
|
0
|
|
|
|
|
return parse_test( $ts, $th ) if $ts eq 'PARSE_TEST'; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# normalize the date |
|
90
|
0
|
|
|
|
|
|
my $nd = normalize_date( $th->{_DATE} ); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# date not valid? |
|
93
|
0
|
0
|
|
|
|
|
return $CELL->status_err( 'DOCHAZKA_CLI_INVALID_DATE_OR_TIME', args => [ $th->{_DATE} ] ) |
|
94
|
|
|
|
|
|
|
unless $nd; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# make it so |
|
97
|
0
|
|
|
|
|
|
$prompt_date = $nd; |
|
98
|
0
|
|
|
|
|
|
init_prompt(); |
|
99
|
0
|
|
|
|
|
|
return $CELL->status_ok( 'DOCHAZKA_CLI_PROMPT_DATE_CHANGED', args => [ $prompt_date ] ); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 noop |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub noop { |
|
107
|
0
|
0
|
|
0
|
1
|
|
print "Entering " . __PACKAGE__ . "::noop\n" if $debug_mode; |
|
108
|
0
|
|
|
|
|
|
my ( $ts, $th ) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# parse test |
|
111
|
0
|
0
|
|
|
|
|
return parse_test( $ts, $th ) if $ts eq 'PARSE_TEST'; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return $CELL->status_ok( |
|
114
|
|
|
|
|
|
|
'DOCHAZKA_NOOP', |
|
115
|
|
|
|
|
|
|
payload => "This is a placeholder for tab completion" |
|
116
|
|
|
|
|
|
|
); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |