| 1 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | package Footprintless::Command; | ||||||||||||||||||||||||||||||||
| 5 | 15 | $Footprintless::Command::VERSION = '1.29'; | |||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: A factory for building common commands | ||||||||||||||||||||||||||||||||
| 7 | # PODNAME: Footprintless::Command | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 15 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||
| 11 | batch_command | ||||||||||||||||||||||||||||||||
| 12 | command | ||||||||||||||||||||||||||||||||
| 13 | command_options | ||||||||||||||||||||||||||||||||
| 14 | cp_command | ||||||||||||||||||||||||||||||||
| 15 | mkdir_command | ||||||||||||||||||||||||||||||||
| 16 | pipe_command | ||||||||||||||||||||||||||||||||
| 17 | rm_command | ||||||||||||||||||||||||||||||||
| 18 | sed_command | ||||||||||||||||||||||||||||||||
| 19 | tail_command | ||||||||||||||||||||||||||||||||
| 20 | write_command | ||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 15 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 35 | ▶ | sub batch_command { | ||||||||||||||||||||||||||||||
|
Subroutine
batch_command: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 26 | 35 | my ( @commands, $batch_options, $command_options ); | |||||||||||||||||||||||||||||||
| 27 | 35 | (@commands) = @_; | |||||||||||||||||||||||||||||||
| 28 | 35 | ▶ | $command_options = pop(@commands) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 29 | if ( ref( $commands[$#commands] ) eq 'Footprintless::Command::CommandOptions' ); | ||||||||||||||||||||||||||||||||
| 30 | 35 | ▶ | $batch_options = pop(@commands) if ( ref( $commands[$#commands] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 35 | ▶ | push( @commands, $command_options ) if ($command_options); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | wrap( | ||||||||||||||||||||||||||||||||
| 35 | $batch_options || {}, | ||||||||||||||||||||||||||||||||
| 36 | @commands, | ||||||||||||||||||||||||||||||||
| 37 | 35 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 38 | 35 | return @_; | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | 35 | ▶ | ); | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$batch_options || {}
MC/DC100%1/1
$batch_options || {}
$batch_options
Truth table100%2/2
A
A= $batch_options
| |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 93 | ▶ | sub command { | ||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 44 | wrap( | ||||||||||||||||||||||||||||||||
| 45 | {}, | ||||||||||||||||||||||||||||||||
| 46 | @_, | ||||||||||||||||||||||||||||||||
| 47 | 93 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 48 | 93 | return shift; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | 93 | ); | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 83 | ▶ | sub command_options { | ||||||||||||||||||||||||||||||
|
Subroutine
command_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 83 | return Footprintless::Command::CommandOptions->new(@_); | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 14 | ▶ | sub cp_command { | ||||||||||||||||||||||||||||||
|
Subroutine
cp_command: called CC=14 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 58 | 14 | my ( $source_path, $source_command_options, $destination_path, $destination_command_options, | |||||||||||||||||||||||||||||||
| 59 | %cp_options ); | ||||||||||||||||||||||||||||||||
| 60 | 14 | $source_path = _escape_path(shift); | |||||||||||||||||||||||||||||||
| 61 | 14 | ▶ | $source_command_options = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 62 | if ( ref( $_[0] ) eq 'Footprintless::Command::CommandOptions' ); | ||||||||||||||||||||||||||||||||
| 63 | 14 | $destination_path = _escape_path(shift); | |||||||||||||||||||||||||||||||
| 64 | 14 | ▶ | $destination_command_options = shift | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | if ( ref( $_[0] ) eq 'Footprintless::Command::CommandOptions' ); | ||||||||||||||||||||||||||||||||
| 66 | 14 | %cp_options = @_; | |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 14 | ▶ | $source_command_options = command_options() unless ($source_command_options); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 69 | 14 | ▶ | $destination_command_options = command_options() unless ($destination_command_options); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 14 | my $source_command; | |||||||||||||||||||||||||||||||
| 72 | my $destination_command; | ||||||||||||||||||||||||||||||||
| 73 | 14 | ▶ | if ( $cp_options{file} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | # is a file, so use cat | dd | ||||||||||||||||||||||||||||||||
| 76 | 6 | ▶ | if ( $cp_options{compress} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | 1 | $source_command = command( "gzip -c $source_path", $source_command_options ); | |||||||||||||||||||||||||||||||
| 78 | 1 | $destination_command = | |||||||||||||||||||||||||||||||
| 79 | pipe_command( "gunzip", "dd of=$destination_path", $destination_command_options ); | ||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||
| 82 | 5 | $source_command = command( "cat $source_path", $source_command_options ); | |||||||||||||||||||||||||||||||
| 83 | 5 | $destination_command = | |||||||||||||||||||||||||||||||
| 84 | command( "dd of=$destination_path", $destination_command_options ); | ||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||
| 88 | # is a directory, so use tar or unzip | ||||||||||||||||||||||||||||||||
| 89 | 8 | ▶ | if ( $cp_options{archive} && $cp_options{archive} eq 'zip' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cp_options{"archive"} and $cp_options{"archive"} eq "zip"
MC/DC50%1/2
$cp_options{"archive"} and $cp_options{"archive"} eq "zip"
$cp_options{"archive"}
$cp_options{"archive"} eq "zip"
Truth table66%2/3
A and B
A= $cp_options{"archive"}B= $cp_options{"archive"} eq "zip"
| |||||||||||||||||||||||||||||||||
| 90 | my $temp_zip = File::Spec->catfile( $destination_path, | ||||||||||||||||||||||||||||||||
| 91 | 3 | ▶ | $cp_options{unzip_temp_file} || "temp_cp_command.zip" ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$cp_options{'unzip_temp_file'} || 'temp_cp_command.zip'
MC/DC0%0/1
$cp_options{'unzip_temp_file'} || 'temp_cp_command.zip'
$cp_options{'unzip_temp_file'}
Truth table50%1/2
A
A= $cp_options{'unzip_temp_file'}
| |||||||||||||||||||||||||||||||||
| 92 | 3 | $source_command = | |||||||||||||||||||||||||||||||
| 93 | command( | ||||||||||||||||||||||||||||||||
| 94 | batch_command( "cd $source_path", "zip -qr - .", { subshell => "bash -c " } ), | ||||||||||||||||||||||||||||||||
| 95 | $source_command_options ); | ||||||||||||||||||||||||||||||||
| 96 | 3 | $destination_command = batch_command( | |||||||||||||||||||||||||||||||
| 97 | "dd of=$temp_zip", "unzip -qod $destination_path $temp_zip", | ||||||||||||||||||||||||||||||||
| 98 | rm_command($temp_zip), $destination_command_options | ||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||
| 102 | # default, use tar | ||||||||||||||||||||||||||||||||
| 103 | 5 | my @parts = ("tar -c -C $source_path ."); | |||||||||||||||||||||||||||||||
| 104 | 5 | my @destination_parts = (); | |||||||||||||||||||||||||||||||
| 105 | 5 | ▶ | if ( $cp_options{status} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | push( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | @parts, | ||||||||||||||||||||||||||||||||
| 108 | join( | ||||||||||||||||||||||||||||||||
| 109 | '', | ||||||||||||||||||||||||||||||||
| 110 | 'pv -f -s `', | ||||||||||||||||||||||||||||||||
| 111 | _sudo_command( | ||||||||||||||||||||||||||||||||
| 112 | $source_command_options | ||||||||||||||||||||||||||||||||
| 113 | ? ( $source_command_options->get_sudo_command(), | ||||||||||||||||||||||||||||||||
| 114 | $source_command_options->get_sudo_username() | ||||||||||||||||||||||||||||||||
| 115 | ) | ||||||||||||||||||||||||||||||||
| 116 | : ( undef, undef ), | ||||||||||||||||||||||||||||||||
| 117 | pipe_command( "du -sb $source_path", 'cut -f1' ) | ||||||||||||||||||||||||||||||||
| 118 | ), | ||||||||||||||||||||||||||||||||
| 119 | '`' | ||||||||||||||||||||||||||||||||
| 120 | ) | ||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | 5 | ▶ | if ( $cp_options{compress} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | 2 | push( @parts, 'gzip' ); | |||||||||||||||||||||||||||||||
| 125 | 2 | push( @destination_parts, 'gunzip' ); | |||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||
| 127 | push( | ||||||||||||||||||||||||||||||||
| 128 | 5 | ▶ | @destination_parts, | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 129 | _sudo_command( | ||||||||||||||||||||||||||||||||
| 130 | $destination_command_options | ||||||||||||||||||||||||||||||||
| 131 | ? ( $destination_command_options->get_sudo_command(), | ||||||||||||||||||||||||||||||||
| 132 | $destination_command_options->get_sudo_username() | ||||||||||||||||||||||||||||||||
| 133 | ) | ||||||||||||||||||||||||||||||||
| 134 | : ( undef, undef ), | ||||||||||||||||||||||||||||||||
| 135 | "tar --no-overwrite-dir -x -C $destination_path" | ||||||||||||||||||||||||||||||||
| 136 | ) | ||||||||||||||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | 5 | $source_command = command( pipe_command(@parts), $source_command_options ); | |||||||||||||||||||||||||||||||
| 140 | 5 | $destination_command = command( pipe_command(@destination_parts), | |||||||||||||||||||||||||||||||
| 141 | $destination_command_options->clone( sudo_username => undef ) ); | ||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 14 | return pipe_command( $source_command, $destination_command ); | |||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | 28 | ▶ | sub _escape_path { | ||||||||||||||||||||||||||||||
|
Subroutine
_escape_path: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 149 | 28 | my ($path) = @_; | |||||||||||||||||||||||||||||||
| 150 | 28 | $path =~ s/(['"`\s])/\\$1/g; | |||||||||||||||||||||||||||||||
| 151 | 28 | return $path; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 15 | ▶ | sub mkdir_command { | ||||||||||||||||||||||||||||||
|
Subroutine
mkdir_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 155 | wrap( | ||||||||||||||||||||||||||||||||
| 156 | {}, | ||||||||||||||||||||||||||||||||
| 157 | @_, | ||||||||||||||||||||||||||||||||
| 158 | 15 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 159 | 15 | return 'mkdir -p "' . join( '" "', @_ ) . '"'; | |||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||
| 161 | 15 | ); | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 33 | ▶ | sub pipe_command { | ||||||||||||||||||||||||||||||
|
Subroutine
pipe_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 165 | wrap( | ||||||||||||||||||||||||||||||||
| 166 | { command_separator => '|' }, | ||||||||||||||||||||||||||||||||
| 167 | @_, | ||||||||||||||||||||||||||||||||
| 168 | 33 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 169 | 33 | return @_; | |||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||
| 171 | 33 | ); | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 59 | ▶ | sub _quote_command { | ||||||||||||||||||||||||||||||
|
Subroutine
_quote_command: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 175 | 59 | my ($command) = @_; | |||||||||||||||||||||||||||||||
| 176 | 59 | $command =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||
| 177 | 59 | $command =~ s/\$/\\\$/g; | |||||||||||||||||||||||||||||||
| 178 | 59 | $command =~ s/`/\\`/g; # for `command` | |||||||||||||||||||||||||||||||
| 179 | 59 | $command =~ s/"/\\"/g; | |||||||||||||||||||||||||||||||
| 180 | 59 | return "\"$command\""; | |||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 23 | ▶ | sub rm_command { | ||||||||||||||||||||||||||||||
|
Subroutine
rm_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 184 | Footprintless::Command::wrap( | ||||||||||||||||||||||||||||||||
| 185 | {}, | ||||||||||||||||||||||||||||||||
| 186 | @_, | ||||||||||||||||||||||||||||||||
| 187 | 23 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 188 | 23 | my ( @dirs, @files ); | |||||||||||||||||||||||||||||||
| 189 | 23 | foreach my $entry (@_) { | |||||||||||||||||||||||||||||||
| 190 | 34 | ▶ | if ( $entry =~ /(?:\/|\\)$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | 23 | push( @dirs, $entry ); | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | else { | ||||||||||||||||||||||||||||||||
| 194 | 11 | push( @files, $entry ); | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 23 | ▶ | if (@dirs) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | 17 | ▶ | if (@files) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 200 | 2 | return batch_command( | |||||||||||||||||||||||||||||||
| 201 | 'rm -rf "' . join( '" "', sort(@dirs) ) . '"', | ||||||||||||||||||||||||||||||||
| 202 | 'rm -f "' . join( '" "', sort(@files) ) . '"', | ||||||||||||||||||||||||||||||||
| 203 | { subshell => 'bash -c ' } | ||||||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||
| 206 | else { | ||||||||||||||||||||||||||||||||
| 207 | 15 | return 'rm -rf "' . join( '" "', sort(@dirs) ) . '"'; | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | else { | ||||||||||||||||||||||||||||||||
| 211 | 6 | return 'rm -f "' . join( '" "', sort(@files) ) . '"'; | |||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | 23 | ); | |||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | 2 | ▶ | sub sed_command { | ||||||||||||||||||||||||||||||
|
Subroutine
sed_command: called CC=1 SCAR=0.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 218 | wrap( | ||||||||||||||||||||||||||||||||
| 219 | {}, | ||||||||||||||||||||||||||||||||
| 220 | @_, | ||||||||||||||||||||||||||||||||
| 221 | 2 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=27.6
| |||||||||||||||||||||||||||||||||
| 222 | 2 | my @args = @_; | |||||||||||||||||||||||||||||||
| 223 | 2 | my $options = {}; | |||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | if ( ref( $args[$#args] ) eq 'HASH' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 226 | 1 | $options = pop(@args); | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 2 | my $command = 'sed'; | |||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | $command .= ' -i' if ( $options->{in_place} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 231 | 2 | ▶ | if ( defined( $options->{temp_script_file} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 232 | 0 | my $temp_script_file_name = $options->{temp_script_file}->filename(); | |||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | print( { $options->{temp_script_file} } join( ' ', '', map {"$_;"} @args ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | if ( scalar(@args) ); | ||||||||||||||||||||||||||||||||
| 235 | print( | ||||||||||||||||||||||||||||||||
| 236 | 0 | { $options->{temp_script_file} } join( ' ', | |||||||||||||||||||||||||||||||
| 237 | '', | ||||||||||||||||||||||||||||||||
| 238 | 0 | map {"s/$_/$options->{replace_map}{$_}/g;"} | |||||||||||||||||||||||||||||||
| 239 | 0 | keys( %{ $options->{replace_map} } ) ) | |||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | ) if ( defined( $options->{replace_map} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 0 | $options->{temp_script_file}->flush(); | |||||||||||||||||||||||||||||||
| 242 | 0 | $command .= " -f $temp_script_file_name"; | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | else { | ||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | $command .= join( ' ', '', map {"-e '$_'"} @args ) if ( scalar(@args) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | $command .= join( ' ', | ||||||||||||||||||||||||||||||||
| 247 | '', | ||||||||||||||||||||||||||||||||
| 248 | 1 | map {"-e 's/$_/$options->{replace_map}{$_}/g'"} | |||||||||||||||||||||||||||||||
| 249 | 1 | keys( %{ $options->{replace_map} } ) ) | |||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | if ( defined( $options->{replace_map} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $command .= join( ' ', '', @{ $options->{files} } ) if ( $options->{files} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 2 | return $command; | |||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||
| 256 | 2 | ); | |||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | 295 | ▶ | sub _sudo_command { | ||||||||||||||||||||||||||||||
|
Subroutine
_sudo_command: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||
| 260 | 295 | my ( $sudo_command, $sudo_username, $command ) = @_; | |||||||||||||||||||||||||||||||
| 261 | 295 | ▶ | if ( defined($sudo_username) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | 49 | ▶ | $command = | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 263 | ( $sudo_command ? "$sudo_command " : 'sudo ' ) | ||||||||||||||||||||||||||||||||
| 264 | . ( $sudo_username ? "-u $sudo_username " : '' ) | ||||||||||||||||||||||||||||||||
| 265 | . $command; | ||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | 295 | return $command; | |||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | 10 | ▶ | sub tail_command { | ||||||||||||||||||||||||||||||
|
Subroutine
tail_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 271 | Footprintless::Command::wrap( | ||||||||||||||||||||||||||||||||
| 272 | {}, | ||||||||||||||||||||||||||||||||
| 273 | @_, | ||||||||||||||||||||||||||||||||
| 274 | 10 | ▶ | sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 275 | 10 | my ( $file, %options ) = @_; | |||||||||||||||||||||||||||||||
| 276 | 10 | my @command = ('tail'); | |||||||||||||||||||||||||||||||
| 277 | 10 | ▶ | if ( $options{follow} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 278 | 9 | push( @command, '-f' ); | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | elsif ( $options{lines} ) { | ||||||||||||||||||||||||||||||||
| 281 | 1 | push( @command, '-n', $options{lines} ); | |||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||
| 283 | 10 | push( @command, $file ); | |||||||||||||||||||||||||||||||
| 284 | 10 | return join( ' ', @command ); | |||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||
| 286 | 10 | ); | |||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | 5 | ▶ | sub write_command { | ||||||||||||||||||||||||||||||
|
Subroutine
write_command: called CC=10 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 290 | 5 | my ( $filename, @lines, $write_options, $command_options ); | |||||||||||||||||||||||||||||||
| 291 | 5 | $filename = shift; | |||||||||||||||||||||||||||||||
| 292 | 5 | @lines = @_; | |||||||||||||||||||||||||||||||
| 293 | 5 | ▶ | $command_options = pop(@lines) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 294 | if ( ref( $lines[$#lines] ) eq 'Footprintless::Command::CommandOptions' ); | ||||||||||||||||||||||||||||||||
| 295 | 5 | ▶ | $write_options = pop(@lines) if ( ref( $lines[$#lines] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||
| 297 | 5 | my $remote_command = "dd of=$filename"; | |||||||||||||||||||||||||||||||
| 298 | 5 | ▶ | if ( defined($write_options) && defined( $write_options->{mode} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $write_options and defined $write_options->{"mode"}
MC/DC50%1/2
defined $write_options and defined $write_options->{"mode"}
defined $write_options
defined $write_options->{"mode"}
Truth table66%2/3
A and B
A= defined $write_optionsB= defined $write_options->{"mode"}
| |||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | if ( defined($command_options) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 300 | 3 | $remote_command = | |||||||||||||||||||||||||||||||
| 301 | batch_command( $remote_command, "chmod $write_options->{mode} $filename", | ||||||||||||||||||||||||||||||||
| 302 | $command_options ); | ||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||
| 304 | elsif ( defined($command_options) ) { | ||||||||||||||||||||||||||||||||
| 305 | 0 | $remote_command = | |||||||||||||||||||||||||||||||
| 306 | batch_command( $remote_command, "chmod $write_options->{mode} $filename" ); | ||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | elsif ( defined($command_options) ) { | ||||||||||||||||||||||||||||||||
| 310 | 1 | $remote_command = command( $remote_command, $command_options ); | |||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||
| 313 | my $line_separator = | ||||||||||||||||||||||||||||||||
| 314 | ( defined($write_options) && defined( $write_options->{line_separator} ) ) | ||||||||||||||||||||||||||||||||
| 315 | ? $write_options->{line_separator} | ||||||||||||||||||||||||||||||||
| 316 | 5 | ▶ | : '\n'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $write_options and defined $write_options->{"line_separator"}
MC/DC100%2/2
defined $write_options and defined $write_options->{"line_separator"}
defined $write_options
defined $write_options->{"line_separator"}
Truth table100%3/3
A and B
A= defined $write_optionsB= defined $write_options->{"line_separator"}
| |||||||||||||||||||||||||||||||||
| 317 | 5 | return pipe_command( 'printf "' . join( $line_separator, @lines ) . '"', $remote_command ); | |||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | # Handles wrapping commands with possible ssh and command prefix | ||||||||||||||||||||||||||||||||
| 321 | 211 | ▶ | sub wrap { | ||||||||||||||||||||||||||||||
|
Subroutine
wrap: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 322 | 211 | my $wrap_options = shift; | |||||||||||||||||||||||||||||||
| 323 | 211 | my $builder = pop; | |||||||||||||||||||||||||||||||
| 324 | 211 | my @args = @_; | |||||||||||||||||||||||||||||||
| 325 | 211 | my ( $ssh, $username, $hostname, $sudo_command, $sudo_username, $pretty ); | |||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 211 | ▶ | if ( ref( $args[$#args] ) eq 'Footprintless::Command::CommandOptions' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 328 | 121 | my $options = pop(@args); | |||||||||||||||||||||||||||||||
| 329 | 121 | ▶ | $ssh = $options->get_ssh() || 'ssh'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$options->get_ssh || 'ssh'
MC/DC100%1/1
$options->get_ssh || 'ssh'
$options->get_ssh
Truth table100%2/2
A
A= $options->get_ssh
| |||||||||||||||||||||||||||||||||
| 330 | 121 | $username = $options->get_username(); | |||||||||||||||||||||||||||||||
| 331 | 121 | $hostname = $options->get_hostname(); | |||||||||||||||||||||||||||||||
| 332 | 121 | $sudo_command = $options->get_sudo_command(); | |||||||||||||||||||||||||||||||
| 333 | 121 | $sudo_username = $options->get_sudo_username(); | |||||||||||||||||||||||||||||||
| 334 | 121 | $pretty = $options->get_pretty(); | |||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | 211 | my $destination_command = ''; | |||||||||||||||||||||||||||||||
| 338 | 211 | ▶ | my $command_separator = $wrap_options->{command_separator} || ';'; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$wrap_options->{'command_separator'} || ';'
MC/DC100%1/1
$wrap_options->{'command_separator'} || ';'
$wrap_options->{'command_separator'}
Truth table100%2/2
A
A= $wrap_options->{'command_separator'}
| |||||||||||||||||||||||||||||||||
| 339 | 211 | my $commands = 0; | |||||||||||||||||||||||||||||||
| 340 | 211 | foreach my $command ( &$builder(@args) ) { | |||||||||||||||||||||||||||||||
| 341 | 290 | ▶ | if ( defined($command) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 342 | 289 | ▶ | if ( $commands++ > 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 343 | 78 | $destination_command .= $command_separator; | |||||||||||||||||||||||||||||||
| 344 | 78 | ▶ | if ($pretty) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 345 | 0 | $destination_command .= "\n"; | |||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | 289 | $command =~ s/^(.*?[^\\]);$/$1/; # from find -exec | |||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | 289 | $command = _sudo_command( $sudo_command, $sudo_username, $command ); | |||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 289 | $destination_command .= $command; | |||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | 211 | ▶ | if ( $wrap_options->{subshell} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | 7 | $destination_command = $wrap_options->{subshell} . _quote_command($destination_command); | |||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | 211 | ▶ | if ( !defined($username) && !defined($hostname) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $username or defined $hostname
MC/DC100%2/2
defined $username or defined $hostname
defined $username
defined $hostname
Truth table100%3/3
A or B
A= defined $usernameB= defined $hostname
| |||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | # silly to ssh to localhost as current user, so dont | ||||||||||||||||||||||||||||||||
| 364 | 159 | return $destination_command; | |||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | 52 | ▶ | my $userAt = | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 368 | $username | ||||||||||||||||||||||||||||||||
| 369 | ? ( ( $ssh =~ /plink(?:\.exe)?$/ ) ? "-l $username " : "$username\@" ) | ||||||||||||||||||||||||||||||||
| 370 | : ''; | ||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||
| 372 | 52 | $destination_command = _quote_command($destination_command); | |||||||||||||||||||||||||||||||
| 373 | 52 | ▶ | return "$ssh $userAt" . ( $hostname || 'localhost' ) . " $destination_command"; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$hostname || 'localhost'
MC/DC0%0/1
$hostname || 'localhost'
$hostname
Truth table50%1/2
A
A= $hostname
| |||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||
| 376 | package Footprintless::Command::CommandOptions; | ||||||||||||||||||||||||||||||||
| 377 | 15 | $Footprintless::Command::CommandOptions::VERSION = '1.29'; | |||||||||||||||||||||||||||||||
| 378 | 92 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 379 | 92 | return bless( {}, shift )->_init(@_); | |||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||
| 382 | 9 | ▶ | sub clone { | ||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=13 SCAR=32.8
| |||||||||||||||||||||||||||||||||
| 383 | 9 | my ( $instance, %options ) = @_; | |||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | 9 | ▶ | if ( exists( $instance->{hostname} ) && !exists( $options{hostname} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $instance->{"hostname"} and not exists $options{"hostname"}
MC/DC50%1/2
exists $instance->{"hostname"} and not exists $options{"hostname"}
exists $instance->{"hostname"}
not exists $options{"hostname"}
Truth table66%2/3
A and not(B)
A= exists $instance->{"hostname"}B= not exists $options{"hostname"}
| |||||||||||||||||||||||||||||||||
| 386 | 3 | $options{hostname} = $instance->{hostname}; | |||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||
| 388 | 9 | ▶ | if ( exists( $instance->{ssh} ) && !exists( $options{ssh} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $instance->{"ssh"} and not exists $options{"ssh"}
MC/DC0%0/2
exists $instance->{"ssh"} and not exists $options{"ssh"}
exists $instance->{"ssh"}
not exists $options{"ssh"}
Truth table66%2/3
A and not(B)
A= exists $instance->{"ssh"}B= not exists $options{"ssh"}
| |||||||||||||||||||||||||||||||||
| 389 | 0 | $options{ssh} = $instance->{ssh}; | |||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||
| 391 | 9 | ▶ | if ( exists( $instance->{username} ) && !exists( $options{username} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $instance->{"username"} and not exists $options{"username"}
MC/DC0%0/2
exists $instance->{"username"} and not exists $options{"username"}
exists $instance->{"username"}
not exists $options{"username"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"username"}B= not exists $options{"username"}
| |||||||||||||||||||||||||||||||||
| 392 | 0 | $options{username} = $instance->{username}; | |||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||
| 394 | 9 | ▶ | if ( exists( $instance->{sudo_command} ) && !exists( $options{sudo_command} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $instance->{"sudo_command"} and not exists $options{"sudo_command"}
MC/DC0%0/2
exists $instance->{"sudo_command"} and not exists $options{"sudo_command"}
exists $instance->{"sudo_command"}
not exists $options{"sudo_command"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"sudo_command"}B= not exists $options{"sudo_command"}
| |||||||||||||||||||||||||||||||||
| 395 | 0 | $options{sudo_command} = $instance->{sudo_command}; | |||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||
| 397 | 9 | ▶ | if ( exists( $instance->{sudo_username} ) && !exists( $options{sudo_username} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $instance->{"sudo_username"} and not exists $options{"sudo_username"}
MC/DC0%0/2
exists $instance->{"sudo_username"} and not exists $options{"sudo_username"}
exists $instance->{"sudo_username"}
not exists $options{"sudo_username"}
Truth table66%2/3
A and not(B)
A= exists $instance->{"sudo_username"}B= not exists $options{"sudo_username"}
| |||||||||||||||||||||||||||||||||
| 398 | 0 | $options{sudo_username} = $instance->{sudo_username}; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | 9 | ▶ | if ( exists( $instance->{pretty} ) && !exists( $options{pretty} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $instance->{"pretty"} and not exists $options{"pretty"}
MC/DC0%0/2
exists $instance->{"pretty"} and not exists $options{"pretty"}
exists $instance->{"pretty"}
not exists $options{"pretty"}
Truth table33%1/3
A and not(B)
A= exists $instance->{"pretty"}B= not exists $options{"pretty"}
| |||||||||||||||||||||||||||||||||
| 401 | 0 | $options{pretty} = $instance->{pretty}; | |||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||
| 404 | 9 | return new( ref($instance), %options ); | |||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | 121 | ▶ | sub get_hostname { | ||||||||||||||||||||||||||||||
|
Subroutine
get_hostname: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 408 | 121 | return $_[0]->{hostname}; | |||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | 121 | ▶ | sub get_pretty { | ||||||||||||||||||||||||||||||
|
Subroutine
get_pretty: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 412 | 121 | return $_[0]->{pretty}; | |||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | 121 | ▶ | sub get_ssh { | ||||||||||||||||||||||||||||||
|
Subroutine
get_ssh: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 416 | 121 | return $_[0]->{ssh}; | |||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||
| 419 | 127 | ▶ | sub get_sudo_command { | ||||||||||||||||||||||||||||||
|
Subroutine
get_sudo_command: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 420 | 127 | return $_[0]->{sudo_command}; | |||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | 127 | ▶ | sub get_sudo_username { | ||||||||||||||||||||||||||||||
|
Subroutine
get_sudo_username: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 424 | 127 | return $_[0]->{sudo_username}; | |||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||
| 427 | 121 | ▶ | sub get_username { | ||||||||||||||||||||||||||||||
|
Subroutine
get_username: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 428 | 121 | return $_[0]->{username}; | |||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | 92 | ▶ | sub _init { | ||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||
| 432 | 92 | my ( $self, %options ) = @_; | |||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | 92 | ▶ | $self->{hostname} = $options{hostname} if ( defined( $options{hostname} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 435 | 92 | ▶ | $self->{ssh} = $options{ssh} if ( defined( $options{ssh} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 436 | 92 | ▶ | $self->{username} = $options{username} if ( defined( $options{username} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 437 | 92 | ▶ | $self->{sudo_command} = $options{sudo_command} if ( defined( $options{sudo_command} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 438 | 92 | ▶ | $self->{sudo_username} = $options{sudo_username} if ( defined( $options{sudo_username} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 439 | 92 | ▶ | $self->{pretty} = $options{pretty} if ( defined( $options{pretty} ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | 92 | return $self; | |||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | __END__ | ||||||||||||||||||||||||||||||||