types/Commandline.php
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
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
Properties
Methods

createArgument(
boolean $insertAtStart
=
false
)
:
\CommandlineArgumentCreates an argument object and adds it to our list of args.
Each commandline object has at most one instance of the argument class.
| Name | Type | Description |
|---|---|---|
| $insertAtStart | boolean | if true, the argument is inserted at the beginning of the list of args, otherwise it is appended. |
| Type | Description |
|---|---|
| \CommandlineArgument |

createMarker(
)
:
\CommandlineMarkerReturn 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.
| Type | Description |
|---|---|
| \CommandlineMarker |

describeArguments(
\$args $args
=
null, \$offset $offset
=
0
)
:
stringReturns a String that describes the arguments suitable for
verbose output before a call to
Runtime.exec(String[])
| Name | Type | Description |
|---|---|---|
| $args | \$args | arguments to use (default is to use current class args) |
| $offset | \$offset | ignore entries before this index |
| Type | Description |
|---|---|
| string |

describeCommand(
array $args
=
null
)
:
stringReturns 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.
| Name | Type | Description |
|---|---|---|
| $args | array | CommandlineArgument[] to use |
| Type | Description |
|---|---|
| string |

getCommandline(
)
:
arrayReturns the executable and all defined arguments.
| Type | Description |
|---|---|
| array |

quoteArgument(
$argument, $escape
=
false
)
:
voidPut 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.
| Name | Type | Description |
|---|---|---|
| $argument | ||
| $escape |
- Exception
- BuildException if the argument contains both, single and double quotes.

setExecutable(
$executable
)
:
voidSets the executable to run.
| Name | Type | Description |
|---|---|---|
| $executable |

toString(
$lines, $escape
=
false
)
:
voidQuotes the parts of the given array in way that makes them usable as command line arguments.
| Name | Type | Description |
|---|---|---|
| $lines | ||
| $escape |
\CommandlineArgument
"Inner" class used for nested xml command line definitions.
Properties
Methods

getParts(
)
:
arrayReturns the parts this Argument consists of.
| Type | Description |
|---|---|
| array | string[] |

setFile(
\value $value
)
:
voidSets a single commandline argument to the absolute filename of the given file.
| Name | Type | Description |
|---|---|---|
| $value | \value | a single commandline argument. |

setLine(
\line $line
)
:
voidLine to split into several commandline arguments.
| Name | Type | Description |
|---|---|---|
| $line | \line | line to split into several commandline arguments |

setPath(
\value $value
)
:
voidSets a single commandline argument and treats it like a PATH - ensures the right separator for the local platform is used.
| Name | Type | Description |
|---|---|---|
| $value | \value | a single commandline argument. |