com.compomics.software
Class CommandLineUtils

java.lang.Object
  extended by com.compomics.software.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
static String SEPARATOR
          The command line argument separator.
 
Constructor Summary
CommandLineUtils()
           
 
Method Summary
static String concatenate(ArrayList<String> args)
          Returns the list of arguments as space separated string for the command line.
static String concatenate(String[] args)
          Returns the list of arguments as space separated string for the command line.
static String getCommandLineArgument(ArrayList<File> files)
          Returns the list of file as argument for the command line.
static String getCommandLineArgument(File file)
          Returns the file as argument for the command line.
static ArrayList<File> getFiles(String optionInput, ArrayList<String> fileExtentions)
          Returns a list of files as imported from the 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final String SEPARATOR
The command line argument separator.

See Also:
Constant Field Values
Constructor Detail

CommandLineUtils

public CommandLineUtils()
Method Detail

getCommandLineArgument

public static String getCommandLineArgument(ArrayList<File> files)
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

public static String concatenate(ArrayList<String> args)
Returns the list of arguments as space separated string for the command line.

Parameters:
args - the arguments
Returns:
a comma separated string

concatenate

public static String concatenate(String[] args)
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

public static String getQuoteType()
Returns the quote type to use. For example around file paths with spaces.

Returns:
the quote type to use

getCommandLineArgument

public static String getCommandLineArgument(File file)
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

public static ArrayList<String> splitInput(String cliInput)
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> fileExtentions)
                                throws FileNotFoundException
Returns a list of files as imported from the command line option.

Parameters:
optionInput - the command line option
fileExtentions - the file extensions to be considered
Returns:
a list of file candidates
Throws:
FileNotFoundException - exception thrown whenever a file is not found


Copyright © 2013. All Rights Reserved.