org.codehaus.plexus.util.cli
Class CommandLineUtils
java.lang.Object
org.codehaus.plexus.util.cli.CommandLineUtils
public abstract class CommandLineUtils
extends java.lang.Object
$Id: CommandLineUtils.java 5960 2007-02-28 22:35:43Z jdcasey $
static int | executeCommandLine(Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr)
|
static int | executeCommandLine(Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr)
|
static Properties | getSystemEnvVars()
|
static Properties | getSystemEnvVars(boolean caseSensitive) - Return the shell environment variables.
|
static boolean | isAlive(long pid)
|
static void | killProcess(long pid) - Kill a process launched by executeCommandLine methods
Doesn't work correctly on windows, only the cmd process will be destroy but not the sub process (Bug ID 4770092)
|
static String | quote(String argument) - Put quotes around the given String if necessary.
|
static String | quote(String argument, boolean wrapExistingQuotes) - Put quotes around the given String if necessary.
|
static String | quote(String argument, boolean escapeSingleQuotes, boolean escapeDoubleQuotes, boolean wrapExistingQuotes)
|
static String | toString(String[] line)
|
static String[] | translateCommandline(String toProcess)
|
getSystemEnvVars
public static Properties getSystemEnvVars()
throws IOException
getSystemEnvVars
public static Properties getSystemEnvVars(boolean caseSensitive)
throws IOException
Return the shell environment variables. If caseSensitive == true
, then envar
keys will all be upper-case.
caseSensitive
- Whether environment variable keys should be treated case-sensitively.
- Properties object of (possibly modified) envar keys mapped to their values.
isAlive
public static boolean isAlive(long pid)
killProcess
public static void killProcess(long pid)
Kill a process launched by executeCommandLine methods
Doesn't work correctly on windows, only the cmd process will be destroy but not the sub process (
Bug ID 4770092)
pid
- The pid of command return by Commandline.getPid()
quote
public static String quote(String argument)
throws CommandLineException
Put quotes around the given String if necessary.
If the argument doesn't include spaces or quotes, return it
as is. If it contains double quotes, use single quotes - else
surround the argument by double quotes.
quote
public static String quote(String argument,
boolean wrapExistingQuotes)
throws CommandLineException
Put quotes around the given String if necessary.
If the argument doesn't include spaces or quotes, return it
as is. If it contains double quotes, use single quotes - else
surround the argument by double quotes.
quote
public static String quote(String argument,
boolean escapeSingleQuotes,
boolean escapeDoubleQuotes,
boolean wrapExistingQuotes)
throws CommandLineException
toString
public static String toString(String[] line)
translateCommandline
public static String[] translateCommandline(String toProcess)
throws Exception