Package org.sonar.api.utils.command
Class Command
- java.lang.Object
-
- org.sonar.api.utils.command.Command
-
public class Command extends java.lang.Object- Since:
- 2.7
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandaddArgument(java.lang.String arg)CommandaddArguments(java.lang.String[] args)CommandaddArguments(java.util.List<java.lang.String> args)CommandaddMaskedArgument(java.lang.String arg)static Commandcreate(java.lang.String executable)Create a command line without any argumentsjava.util.List<java.lang.String>getArguments()java.io.FilegetDirectory()java.util.Map<java.lang.String,java.lang.String>getEnvironmentVariables()Environment variables that are propagated during command execution.java.lang.StringgetExecutable()booleanisNewShell()trueif a new shell should be used to execute the command.CommandsetDirectory(java.io.File d)Sets working directory.CommandsetEnvironmentVariable(java.lang.String name, java.lang.String value)CommandsetNewShell(boolean b)Set totrueif a new shell should be used to execute the command.java.lang.StringtoCommandLine()java.lang.StringtoString()
-
-
-
Method Detail
-
create
public static Command create(java.lang.String executable)
Create a command line without any arguments- Parameters:
executable-
-
getExecutable
public java.lang.String getExecutable()
-
getArguments
public java.util.List<java.lang.String> getArguments()
-
addArgument
public Command addArgument(java.lang.String arg)
-
addMaskedArgument
public Command addMaskedArgument(java.lang.String arg)
-
addArguments
public Command addArguments(java.util.List<java.lang.String> args)
-
addArguments
public Command addArguments(java.lang.String[] args)
-
getDirectory
public java.io.File getDirectory()
-
setDirectory
public Command setDirectory(java.io.File d)
Sets working directory.
-
setEnvironmentVariable
public Command setEnvironmentVariable(java.lang.String name, java.lang.String value)
- Since:
- 3.2
- See Also:
getEnvironmentVariables()
-
getEnvironmentVariables
public java.util.Map<java.lang.String,java.lang.String> getEnvironmentVariables()
Environment variables that are propagated during command execution. The initial value is a copy of the environment of the current process.- Returns:
- a non-null and immutable map of variables
- Since:
- 3.2
-
isNewShell
public boolean isNewShell()
trueif a new shell should be used to execute the command. The default behavior is to not use a new shell.- Since:
- 3.3
-
setNewShell
public Command setNewShell(boolean b)
Set totrueif a new shell should be used to execute the command. This is useful when the executed command is a script with no execution rights (+x on unix). On windows, the command will be executed withcmd /C executable. On other platforms, the command will be executed withsh executable.- Since:
- 3.3
-
toCommandLine
public java.lang.String toCommandLine()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-