org.codehaus.plexus.util.cli
public class Commandline extends Object implements Cloneable
<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.
Nested Class Summary | |
---|---|
static class | Commandline.Argument |
class | Commandline.Marker
Class to keep track of the position of an Argument. |
Field Summary | |
---|---|
protected Vector | arguments |
protected Map | envVars |
protected String | executable |
protected static String | OS_NAME |
long | pid |
Shell | shell |
File | workingDir |
protected static String | WINDOWS |
Constructor Summary | |
---|---|
Commandline(String toProcess, Shell shell)
Create a new command line object.
| |
Commandline(Shell shell)
Create a new command line object.
| |
Commandline(String toProcess)
Create a new command line object.
| |
Commandline()
Create a new command line object.
|
Method Summary | |
---|---|
void | addArg(Arg argument)
Adds an argument object to our list of args.
|
void | addArg(Arg argument, boolean insertAtStart)
Adds an argument object to our list of args.
|
void | addArguments(String[] line) |
void | addEnvironment(String name, String value)
Add an environment variable |
void | addSystemEnvironment()
Add system environment variables |
void | clear()
Clear out the whole command line. |
void | clearArgs()
Clear out the arguments but leave the executable in place for another operation. |
Object | clone() |
Arg | createArg()
Creates an argument object.
|
Arg | createArg(boolean insertAtStart)
Creates an argument object and adds it to our list of args.
|
Commandline.Argument | createArgument()
Creates an argument object.
|
Commandline.Argument | createArgument(boolean insertAtStart)
Creates an argument object and adds it to our list of args.
|
Commandline.Marker | createMarker()
Return a marker.
|
Process | execute()
Executes the command. |
String[] | getArguments()
Returns all arguments defined by addLine ,
addValue or the argument object. |
String[] | getCommandline()
Returns the executable and all defined arguments. |
String[] | getEnvironmentVariables()
Return the list of environment variables |
String | getExecutable() |
long | getPid() |
Shell | getShell()
Get the shell to be used in this command line.
|
String[] | getShellCommandline()
Returns the shell, executable and all defined arguments. |
Properties | getSystemEnvVars() |
File | getWorkingDirectory() |
static String | quoteArgument(String argument) |
void | setDefaultShell() Sets the shell or command-line interpretor for the detected operating system, and the shell arguments. |
void | setExecutable(String executable)
Sets the executable to run. |
void | setPid(long pid) |
void | setShell(Shell shell)
Allows to set the shell to be used in this command line.
|
void | setWorkingDirectory(String path)
Sets execution directory. |
void | setWorkingDirectory(File workingDirectory)
Sets execution directory. |
int | size() |
String | toString() |
static String | toString(String[] line) |
static String[] | translateCommandline(String toProcess) |
void | verifyShellState() |
Deprecated: Use setExecutable instead.
Deprecated: Use setWorkingDirectory or setWorkingDirectory instead.
Parameters: toProcess
Parameters: toProcess
Returns: the argument object.
See Also: Commandline
Parameters: insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.
Each commandline object has at most one instance of the
argument class. This method calls
this.createArgument(false)
.
Returns: the argument object.
See Also: Commandline
Each commandline object has at most one instance of the argument class.
Parameters: insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.
Deprecated: Use createArg instead
Creates an argument object.Each commandline object has at most one instance of the
argument class. This method calls
this.createArgument(false)
.
Returns: the argument object.
See Also: Commandline
Deprecated: Use Commandline instead
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: insertAtStart if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.
This marker can be used to locate a position on the commandline - to insert something for example - when all parameters have been set.
addLine
,
addValue
or the argument object.Since: 1.2
Deprecated: Use quote instead.
Sets the shell or command-line interpretor for the detected operating system, and the shell arguments.
Parameters: shell
Since: 1.2
Deprecated: Use (String[])
instead.
Deprecated: Use translateCommandline instead.
Deprecated: Remove once backward compat with plexus-utils <= 1.4 is no longer a consideration