line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##################################################################### |
2
|
|
|
|
|
|
|
# This program is not guaranteed to work at all, and by using this # |
3
|
|
|
|
|
|
|
# program you release the author of any and all liability. # |
4
|
|
|
|
|
|
|
# # |
5
|
|
|
|
|
|
|
# You may use this code as long as you are in compliance with the # |
6
|
|
|
|
|
|
|
# license (see the LICENSE file) and this notice, disclaimer and # |
7
|
|
|
|
|
|
|
# comment box remain intact and unchanged. # |
8
|
|
|
|
|
|
|
# # |
9
|
|
|
|
|
|
|
# Package: Term::RouterCLI # |
10
|
|
|
|
|
|
|
# Class: Base # |
11
|
|
|
|
|
|
|
# Description: Methods for building a router (Stanford) style CLI # |
12
|
|
|
|
|
|
|
# # |
13
|
|
|
|
|
|
|
# Written by: Bret Jordan (jordan at open1x littledot org) # |
14
|
|
|
|
|
|
|
# Created: 2011-10-06 # |
15
|
|
|
|
|
|
|
##################################################################### |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
package Term::RouterCLI::Base; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
1785
|
use 5.8.8; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
164
|
|
23
|
4
|
|
|
4
|
|
20
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
114
|
|
24
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
137
|
|
25
|
4
|
|
|
4
|
|
1982
|
use Term::RouterCLI::Config; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
125
|
|
26
|
4
|
|
|
4
|
|
25
|
use Term::RouterCLI::Debugger; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1262
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
29
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new |
34
|
|
|
|
|
|
|
{ |
35
|
3
|
|
|
3
|
0
|
61
|
my $pkg = shift; |
36
|
3
|
|
33
|
|
|
25
|
my $class = ref($pkg) || $pkg; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
7
|
my $self = {}; |
39
|
3
|
|
|
|
|
10
|
$self->{'_sName'} = $pkg; # Lets set the object name so we can use it in debugging |
40
|
3
|
|
|
|
|
17
|
bless ($self, $class); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Lets send any passed in arguments to the _init method |
43
|
3
|
|
|
|
|
38
|
$self->_init(@_); |
44
|
0
|
|
|
|
|
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub DESTROY |
48
|
|
|
|
|
|
|
{ |
49
|
0
|
|
|
0
|
|
|
my $self = shift; |
50
|
0
|
|
|
|
|
|
$self = {}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _initDebugger |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
0
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
# Create an object to the debugger class |
57
|
0
|
|
|
|
|
|
$self->{'_oDebugger'} = new Term::RouterCLI::Debugger(); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _initConfig |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
0
|
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
# Create an object to the debugger class |
64
|
0
|
|
|
|
|
|
$self->{'_oConfig'} = new Term::RouterCLI::Config(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _ExpandTildes |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
0
|
|
|
my $self = shift; |
71
|
0
|
|
|
|
|
|
my $parameter = shift; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
0
|
|
|
|
$parameter =~ s/^~([^\/]*)/$1?(getpwnam($1))[7]:$ENV{HOME}||$ENV{LOGDIR}||(getpwuid($>))[7]/e; |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $parameter; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return 1; |