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 Command
addArgument(java.lang.String arg)
Command
addArguments(java.lang.String[] args)
Command
addArguments(java.util.List<java.lang.String> args)
Command
addMaskedArgument(java.lang.String arg)
static Command
create(java.lang.String executable)
Create a command line without any argumentsjava.util.List<java.lang.String>
getArguments()
java.io.File
getDirectory()
java.util.Map<java.lang.String,java.lang.String>
getEnvironmentVariables()
Environment variables that are propagated during command execution.java.lang.String
getExecutable()
boolean
isNewShell()
true
if a new shell should be used to execute the command.Command
setDirectory(java.io.File d)
Sets working directory.Command
setEnvironmentVariable(java.lang.String name, java.lang.String value)
Command
setNewShell(boolean b)
Set totrue
if a new shell should be used to execute the command.java.lang.String
toCommandLine()
java.lang.String
toString()
-
-
-
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()
true
if 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 totrue
if 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:
toString
in classjava.lang.Object
-
-