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 Details

  • Constructor Details

  • Method Details

    • 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> fileExtensions) throws FileNotFoundException
      Returns a list of files as imported from the command line option.
      Parameters:
      optionInput - the command line option
      fileExtensions - the file extensions to be considered
      Returns:
      a list of file candidates
      Throws:
      FileNotFoundException - exception thrown whenever a file is not found
    • getIntegerListFromString

      public static ArrayList<Integer> getIntegerListFromString​(String aString, String separator)
      Parses a list of integers from a command line option.
      Parameters:
      aString - the command line option
      separator - the separator used to separate the string
      Returns:
      the list if integers
    • getDoubleListFromString

      public static ArrayList<Double> getDoubleListFromString​(String aString, String separator)
      Parses a list of doubles from a command line option.
      Parameters:
      aString - the command line option
      separator - the separator used to separate the string
      Returns:
      the list if doubles