types/Commandline.php

Show: inherited
Table of Contents

Commandline objects help handling command lines specifying processes to execute.

The class can be used to define a command line as nested elements or as a helper to define a command line by an application.

<

p>

<someelement>
  <acommandline executable="/executable/to/run">
    <argument value="argument 1" />
    <argument line="argument_1 argument_2 argument_3" />
    <argument value="argument 4" />
  </acommandline>
</someelement>

The element

someelement

must provide a method

createAcommandline

which returns an instance of this class.

Author
thomas.haas@softwired-inc.com  
Author
Stefan Bodewig  
Package
phing.types  

\Commandline

Package: phing\types

Commandline objects help handling command lines specifying processes to execute.

The class can be used to define a command line as nested elements or as a helper to define a command line by an application.

<

p>

<someelement>
  <acommandline executable="/executable/to/run">
    <argument value="argument 1" />
    <argument line="argument_1 argument_2 argument_3" />
    <argument value="argument 4" />
  </acommandline>
</someelement>

The element

someelement

must provide a method

createAcommandline

which returns an instance of this class.

Author
thomas.haas@softwired-inc.com  
Author
Stefan Bodewig  

Constants

Constant  DISCLAIMER = "The ' characters around the executable and arguments are not part of the command."

Properties

Propertypublicarray  $arguments= 'array()'

CommandlineArguments[]
Default valuearray()Details
Type
array
Propertypublicstring  $executable= ''

Full path (if not on %PATH% env var) to executable program.

Details
Type
string

Methods

methodpublic__construct(  $to_process = null ) : void

Parameters
Name Type Description
$to_process
methodpublic__copy( ) : void

methodpublic__toString( ) : void

methodpublicaddArguments(  $line ) : void

Parameters
Name Type Description
$line
methodpublicclear( ) : void

Clear out the whole command line.

methodpublicclearArgs( ) : void

Clear out the arguments but leave the executable in place for another operation.

methodpubliccreateArgument( boolean $insertAtStart = false ) : \CommandlineArgument

Creates an argument object and adds it to our list of args.

Each commandline object has at most one instance of the argument class.

Parameters
Name Type Description
$insertAtStart boolean

if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.

Returns
Type Description
\CommandlineArgument
methodpubliccreateMarker( ) : \CommandlineMarker

Return a marker.

This marker can be used to locate a position on the commandline - to insert something for example - when all parameters have been set.

Returns
Type Description
\CommandlineMarker
methodprotecteddescribeArguments( \$args $args = null, \$offset $offset = 0 ) : string

Returns a String that describes the arguments suitable for verbose output before a call to Runtime.exec(String[])

Parameters
Name Type Description
$args \$args

arguments to use (default is to use current class args)

$offset \$offset

ignore entries before this index

Returns
Type Description
string
methodpublicdescribeCommand( array $args = null ) : string

Returns a String that describes the command and arguments suitable for verbose output before a call to Runtime.exec(String[]).

This method assumes that the first entry in the array is the executable to run.

Parameters
Name Type Description
$args array

CommandlineArgument[] to use

Returns
Type Description
string
methodpublicgetArguments( ) : void

Returns all arguments defined by addLine, addValue or the argument object.

methodpublicgetCommandline( ) : array

Returns the executable and all defined arguments.

Returns
Type Description
array
methodpublicgetExecutable( ) : void

methodpublicquoteArgument(  $argument,  $escape = false ) : void
static

Put quotes around the given String if necessary.

If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.

Parameters
Name Type Description
$argument
$escape
Details
Exception
BuildException if the argument contains both, single and double quotes.  
methodpublicsetExecutable(  $executable ) : void

Sets the executable to run.

Parameters
Name Type Description
$executable
methodpublicsize( ) : int

Returns
Type Description
int Number of components in current commandline.
methodpublictoString(  $lines,  $escape = false ) : void
static

Quotes the parts of the given array in way that makes them usable as command line arguments.

Parameters
Name Type Description
$lines
$escape
methodpublictranslateCommandline( string $to_process ) : array
static

Parameters
Name Type Description
$to_process string
Returns
Type Description
array

\CommandlineArgument

Package: phing\types

"Inner" class used for nested xml command line definitions.

Properties

Propertyprivate  $outer= ''
Details
Type
n/a
Propertyprivate  $parts= 'array()'
Default valuearray()Details
Type
n/a

Methods

methodpublic__construct(  $outer ) : void

Parameters
Name Type Description
$outer
methodpublicgetParts( ) : array

Returns the parts this Argument consists of.

Returns
Type Description
array string[]
methodpublicsetFile( \value $value ) : void

Sets a single commandline argument to the absolute filename of the given file.

Parameters
Name Type Description
$value \value

a single commandline argument.

methodpublicsetLine( \line $line ) : void

Line to split into several commandline arguments.

Parameters
Name Type Description
$line \line

line to split into several commandline arguments

methodpublicsetPath( \value $value ) : void

Sets a single commandline argument and treats it like a PATH - ensures the right separator for the local platform is used.

Parameters
Name Type Description
$value \value

a single commandline argument.

methodpublicsetValue( string $value ) : void

Sets a single commandline argument.

Parameters
Name Type Description
$value string

a single commandline argument.

\CommandlineMarker

Package: phing\types

Class to keep track of the position of an Argument.

This class is there to support the srcfile and targetfile elements of <execon> and <transform> - don't know whether there might be additional use cases.

--SB

Properties

Propertyprivate  $outer= ''
Details
Type
n/a
Propertyprivate  $position= ''
Details
Type
n/a
Propertyprivate  $realPos= '-1'
Default value-1Details
Type
n/a

Methods

methodpublic__construct(  $outer,  $position ) : void

Parameters
Name Type Description
$outer
$position
methodpublicgetPosition( ) : void

Return the number of arguments that preceeded this marker.

The name of the executable - if set - is counted as the very first argument.

Documentation was generated by DocBlox 0.18.1.