Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.codehaus.plexus.util.cli.Commandline
public class Commandline
extends java.lang.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 | |
class |
|
Field Summary | |
protected static String | |
protected static String | |
protected Vector | |
protected Vector | |
protected String |
|
Constructor Summary | |
| |
| |
| |
|
Method Summary | |
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
Object |
|
Arg |
|
Arg |
|
Commandline.Argument |
|
Commandline.Argument |
|
Commandline.Marker |
|
Process |
|
String[] |
|
String[] |
|
String[] |
|
String | |
long |
|
Shell |
|
String[] |
|
Properties | |
File | |
static String |
|
void |
|
void |
|
void | |
void |
|
void |
|
int |
|
String |
|
static String |
|
static String[] |
|
protected static final String OS_NAME
protected static final String WINDOWS
protected Vector arguments
protected Vector envVars
public Commandline()
Create a new command line object. Shell is autodetected from operating system
public Commandline(String toProcess)
Create a new command line object. Shell is autodetected from operating system
- Parameters:
toProcess
-
public Commandline(String toProcess, Shell shell)
Create a new command line object. Shell is autodetected from operating system
- Parameters:
toProcess
-
public Commandline(Shell shell)
Create a new command line object. Shell is autodetected from operating system
public void addArg(Arg argument)
Adds an argument object to our list of args.
- See Also:
addArg(Arg,boolean)
public void addArg(Arg argument, boolean insertAtStart)
Adds an argument object to our list of args.
- Parameters:
insertAtStart
- if true, the argument is inserted at the beginning of the list of args, otherwise it is appended.
public void addArguments(String[] line)
public void addEnvironment(String name, String value)
Add an environment variable
public void addSystemEnvironment() throws Exception
Add system environment variables
public void clear()
Clear out the whole command line.
public void clearArgs()
Clear out the arguments but leave the executable in place for another operation.
public Object clone()
public Arg createArg()
Creates an argument object. Each commandline object has at most one instance of the argument class. This method callsthis.createArgument(false)
.
- Returns:
- the argument object.
- See Also:
createArgument(boolean)
public Arg createArg(boolean insertAtStart)
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.
public Commandline.Argument createArgument()
Deprecated. Use
createArg()
insteadCreates an argument object. Each commandline object has at most one instance of the argument class. This method callsthis.createArgument(false)
.
- Returns:
- the argument object.
- See Also:
createArgument(boolean)
public Commandline.Argument createArgument(boolean insertAtStart)
Deprecated. Use
createArg(boolean)
insteadCreates 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.
public Commandline.Marker createMarker()
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.
public String[] getArguments()
Returns all arguments defined byaddLine
,addValue
or the argument object.
public String[] getCommandline()
Returns the executable and all defined arguments.
public String[] getEnvironmentVariables() throws CommandLineException
Return the list of environment variables
public String getExecutable()
public long getPid()
public String[] getShellCommandline()
Returns the shell, executable and all defined arguments.
public Properties getSystemEnvVars() throws Exception
public File getWorkingDirectory()
public static String quoteArgument(String argument) throws CommandLineException
Deprecated. Use
CommandLineUtils.quote(String)
instead.
public void setExecutable(String executable)
Sets the executable to run.
public void setPid(long pid)
public void setShell(Shell shell)
Allows to set the shell to be used in this command line.
- Parameters:
shell
-
- Since:
- 1.2
public void setWorkingDirectory(File workingDirectory)
Sets execution directory.
public void setWorkingDirectory(String path)
Sets execution directory.
public int size()
public String toString()
public static String toString(String[] line)
Deprecated. Use
CommandLineUtils.toString(String[])
instead.
public static String[] translateCommandline(String toProcess) throws Exception
Deprecated. Use
CommandLineUtils.translateCommandline(String)
instead.