Class CommandUtils
- java.lang.Object
-
- com.microsoft.azure.toolkit.lib.common.utils.CommandUtils
-
public class CommandUtils extends Object
copied from: https://github.com/microsoft/azure-tools-for-java/blob/ 0efe5e430305369e17dadc214c256cbb4a906372/Utils/azuretools-core/src/com/microsoft/azuretools/utils/CommandUtils.java
-
-
Field Summary
Fields Modifier and Type Field Description private static StringDEFAULT_MAC_LINUX_PATHprivate static StringDEFAULT_WINDOWS_SYSTEM_ROOTprivate static Map<String,String>ENVprivate static StringLINUX_MAC_STARTERprivate static StringLINUX_MAC_SWITCHERprivate static StringWINDOWS_STARTERprivate static StringWINDOWS_SWITCHER
-
Constructor Summary
Constructors Constructor Description CommandUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringexec(String commandWithArgs)static Stringexec(String commandWithArgs, String cwd)static Stringexec(String commandWithArgs, String cwd, boolean mergeErrorStream)static Stringexec(String commandWithArgs, Map<String,String> env)static Stringexec(String commandWithArgs, Map<String,String> env, String cwd)static Stringexec(String commandWithArgs, Map<String,String> env, String cwd, boolean mergeErrorStream)private static StringexecuteCommandAndGetOutput(String starter, String switcher, String commandWithArgs, File directory, Map<String,String> env, boolean mergeErrorStream)private static StringexecuteCommandAndGetOutput(org.apache.commons.exec.CommandLine commandLine, File directory, Map<String,String> env, boolean mergeErrorStream)private static StringgetSafeWorkingDirectory()static booleanisWindows()static booleanisWSL()private static Map<String,String>loadProcessEnvironment()static List<String>resolveCommandPath(String command)static voidsetEnv(Map<String,String> env)
-
-
-
Field Detail
-
WINDOWS_STARTER
private static final String WINDOWS_STARTER
- See Also:
- Constant Field Values
-
LINUX_MAC_STARTER
private static final String LINUX_MAC_STARTER
- See Also:
- Constant Field Values
-
WINDOWS_SWITCHER
private static final String WINDOWS_SWITCHER
- See Also:
- Constant Field Values
-
LINUX_MAC_SWITCHER
private static final String LINUX_MAC_SWITCHER
- See Also:
- Constant Field Values
-
DEFAULT_WINDOWS_SYSTEM_ROOT
private static final String DEFAULT_WINDOWS_SYSTEM_ROOT
-
DEFAULT_MAC_LINUX_PATH
private static final String DEFAULT_MAC_LINUX_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
exec
public static String exec(String commandWithArgs) throws IOException
- Throws:
IOException
-
exec
public static String exec(String commandWithArgs, String cwd) throws IOException
- Throws:
IOException
-
exec
public static String exec(String commandWithArgs, Map<String,String> env) throws IOException
- Throws:
IOException
-
exec
public static String exec(String commandWithArgs, Map<String,String> env, String cwd) throws IOException
- Throws:
IOException
-
exec
public static String exec(String commandWithArgs, String cwd, boolean mergeErrorStream) throws IOException
- Throws:
IOException
-
exec
public static String exec(String commandWithArgs, Map<String,String> env, String cwd, boolean mergeErrorStream) throws IOException
- Throws:
IOException
-
executeCommandAndGetOutput
private static String executeCommandAndGetOutput(String starter, String switcher, String commandWithArgs, File directory, Map<String,String> env, boolean mergeErrorStream) throws IOException
- Throws:
IOException
-
executeCommandAndGetOutput
private static String executeCommandAndGetOutput(org.apache.commons.exec.CommandLine commandLine, File directory, Map<String,String> env, boolean mergeErrorStream) throws IOException
- Throws:
IOException
-
isWindows
public static boolean isWindows()
-
isWSL
public static boolean isWSL()
-
getSafeWorkingDirectory
private static String getSafeWorkingDirectory()
-
-