Package com.compomics.software.cli
Class CommandLineUtils
java.lang.Object
com.compomics.software.cli.CommandLineUtils
public class CommandLineUtils extends Object
This class groups some convenience methods for the use of compomics tools in
command line.
- Author:
- Marc Vaudel
-
Field Summary
-
Constructor Summary
Constructors Constructor Description CommandLineUtils()
-
Method Summary
Modifier and Type Method Description static String
concatenate(String[] args)
Returns the list of arguments as space separated string for the command line.static String
concatenate(ArrayList<String> args)
Returns the list of arguments as space separated string for the command line.static String
getCommandLineArgument(File file)
Returns the file as argument for the command line.static String
getCommandLineArgument(ArrayList<File> files)
Returns the list of file as argument for the command line.static ArrayList<Double>
getDoubleListFromString(String aString, String separator)
Parses a list of doubles from a command line option.static ArrayList<File>
getFiles(String optionInput, ArrayList<String> fileExtensions)
Returns a list of files as imported from the command line option.static ArrayList<Integer>
getIntegerListFromString(String aString, String separator)
Parses a list of integers from a command line option.static String
getQuoteType()
Returns the quote type to use.static ArrayList<String>
splitInput(String cliInput)
Splits the input of comma separated command line input and returns the results as an arraylist.
-
Field Details
-
FORMATTER
The format to use for string output.- See Also:
- Constant Field Values
-
SEPARATOR
The command line argument separator.- See Also:
- Constant Field Values
-
-
Constructor Details
-
CommandLineUtils
public CommandLineUtils()
-
-
Method Details
-
getCommandLineArgument
Returns the list of file as argument for the command line.- Parameters:
files
- the files- Returns:
- the list of file as string for command line argument
-
concatenate
Returns the list of arguments as space separated string for the command line.- Parameters:
args
- the arguments- Returns:
- a comma separated string
-
concatenate
Returns the list of arguments as space separated string for the command line. Adds quotes where they seem to be needed.- Parameters:
args
- the arguments- Returns:
- a comma separated string
-
getQuoteType
Returns the quote type to use. For example around file paths with spaces.- Returns:
- the quote type to use
-
getCommandLineArgument
Returns the file as argument for the command line.- Parameters:
file
- the file- Returns:
- the list of file as string for command line argument
-
splitInput
Splits the input of comma separated command line input and returns the results as an arraylist.- Parameters:
cliInput
- the CLI input- Returns:
- an arraylist containing the results, empty list if empty string
-
getFiles
public static ArrayList<File> getFiles(String optionInput, ArrayList<String> fileExtensions) throws FileNotFoundExceptionReturns a list of files as imported from the command line option.- Parameters:
optionInput
- the command line optionfileExtensions
- the file extensions to be considered- Returns:
- a list of file candidates
- Throws:
FileNotFoundException
- exception thrown whenever a file is not found
-
getIntegerListFromString
Parses a list of integers from a command line option.- Parameters:
aString
- the command line optionseparator
- the separator used to separate the string- Returns:
- the list if integers
-
getDoubleListFromString
Parses a list of doubles from a command line option.- Parameters:
aString
- the command line optionseparator
- the separator used to separate the string- Returns:
- the list if doubles
-