| 1 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | |||||||||||||||
| 4 | package PowerShell::Cmdlet; | ||||||||||||||
| 5 | 3 | $PowerShell::Cmdlet::VERSION = '1.00'; | |||||||||||||
| 6 | # ABSTRACT: Wraps a generic cmdlet | ||||||||||||||
| 7 | # PODNAME: PowerShell::Cmdlet | ||||||||||||||
| 8 | |||||||||||||||
| 9 | 12 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 10 | 12 | return bless( {}, shift )->_init(@_); | |||||||||||||
| 11 | } | ||||||||||||||
| 12 | |||||||||||||||
| 13 | 12 | ▶ | sub command { | ||||||||||||
|
Subroutine
command: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 14 | 12 | my ($self) = @_; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 12 | ▶ | unless ( $self->{command} ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 17 | 12 | my @parts = ( $self->{name} ); | |||||||||||||
| 18 | 12 | foreach my $parameter ( @{ $self->{parameters} } ) { | |||||||||||||
| 19 | 8 | ▶ | if ( scalar(@$parameter) == 2 ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 20 | 6 | push( @parts, "-$parameter->[0] '$parameter->[1]'" ); | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | else { | ||||||||||||||
| 23 | 2 | push( @parts, "'$parameter->[0]'" ); | |||||||||||||
| 24 | } | ||||||||||||||
| 25 | } | ||||||||||||||
| 26 | 12 | $self->{command} = join( ' ', @parts ); | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | |||||||||||||||
| 29 | 12 | return $self->{command}; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 12 | ▶ | sub _init { | ||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 12 | my ( $self, $name ) = @_; | |||||||||||||
| 34 | |||||||||||||||
| 35 | 12 | $self->{name} = $name; | |||||||||||||
| 36 | 12 | $self->{parameters} = []; | |||||||||||||
| 37 | |||||||||||||||
| 38 | 12 | return $self; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | 8 | ▶ | sub parameter { | ||||||||||||
|
Subroutine
parameter: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 42 | 8 | my ( $self, @parameter ) = @_; | |||||||||||||
| 43 | |||||||||||||||
| 44 | 8 | my $parts = scalar(@parameter); | |||||||||||||
| 45 | 8 | ▶ | if ( $parts == 1 ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 46 | 2 | push( @{ $self->{parameters} }, [ $parameter[0] ] ); | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | elsif ( $parts == 2 ) { | ||||||||||||||
| 49 | 6 | push( @{ $self->{parameters} }, [ $parameter[0] => $parameter[1] ] ); | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | 8 | return $self; | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 3 | 1; | |||||||||||||
| 56 | |||||||||||||||
| 57 | __END__ | ||||||||||||||