Class

com.fulcrumgenomics.sopt.cmdline

CommandLineParser

Related Doc: package cmdline

Permalink

class CommandLineParser[SubCommand] extends CommandLineParserStrings

Class for parsing the command line when we also have sub-commands.

We have two possible entry points: (1) parseSubCommand() for when we have set of sub-commands, each having their own set of arguments, and we use the first argument to get the class's simple name (getSimpleName), and pass the rest of the arguments to a properly instantiated CommandLineProgramParser to parse the arguments and build an instance of that class. (2) parseCommandAndSubCommand for the same case as (1), but when the main program itself also has arguments, which come prior to the name of the command line program.

To route the arguments to build the appropriate program, the parser searches for a command line program that is a sub-class of SubCommand, and creates a CommandLineProgramParser to parse the args and return an instance of the SubCommand.

Constructor arguments for the sub-command classes or command class can be annotated with com.fulcrumgenomics.sopt.arg while constructors themselves can be annotated with clp. The latter may be omitted, but is extremely useful for grouping related sub-commands and having a common description.

SubCommand

the base class for all sub-commands to display and parse on the command line.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CommandLineParser
  2. CommandLineParserStrings
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CommandLineParser(commandLineName: String)(implicit classTag: ClassTag[SubCommand], typeTag: scala.reflect.api.JavaUniverse.TypeTag[SubCommand])

    Permalink

    commandLineName

    the name of the base command line.

    classTag

    the ClassTag of SubCommand , usually inferred.

    typeTag

    the TypeTag of SubCommand , usually inferred.

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to any2stringadd[CommandLineParser[SubCommand]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (CommandLineParser[SubCommand], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to ArrowAssoc[CommandLineParser[SubCommand]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. val ArgumentsSuffix: String

    Permalink
    Definition Classes
    CommandLineParserStrings
  7. val AvailableSubCommands: String

    Permalink

    Error messages

    Error messages

    Definition Classes
    CommandLineParserStrings
  8. val HelpSimilarityFloor: Int

    Permalink

    Similarity floor for when searching for similar sub-command names.

    Similarity floor for when searching for similar sub-command names. *

    Definition Classes
    CommandLineParserStrings
  9. val MinimumSubstringLength: Int

    Permalink
    Definition Classes
    CommandLineParserStrings
  10. val MissingSubCommand: String

    Permalink
    Definition Classes
    CommandLineParserStrings
  11. val SeparatorLine: String

    Permalink

    Section separator

    Section separator

    Definition Classes
    CommandLineParserStrings
  12. val SubCommandDescriptionLineLength: Int

    Permalink

    The maximum line lengths for tool descriptions

    The maximum line lengths for tool descriptions

    Definition Classes
    CommandLineParserStrings
  13. val SubCommandGroupDescriptionColumnLength: Int

    Permalink
    Definition Classes
    CommandLineParserStrings
  14. val SubCommandGroupNameColumnLength: Int

    Permalink

    Lengths for names and descriptions on the command line

    Lengths for names and descriptions on the command line

    Definition Classes
    CommandLineParserStrings
  15. val SubCommandNameColumnLength: Int

    Permalink
    Definition Classes
    CommandLineParserStrings
  16. val UsagePrefix: String

    Permalink

    Section headers

    Section headers

    Definition Classes
    CommandLineParserStrings
  17. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  18. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def commandLine: Option[String]

    Permalink

    The command line with all arguments and values stored after the parseSubCommand() or parseCommandAndSubCommand() was successful, otherwise None.

  20. val commandLineName: String

    Permalink

    the name of the base command line.

    the name of the base command line.

    Definition Classes
    CommandLineParserCommandLineParserStrings
  21. def ensuring(cond: (CommandLineParser[SubCommand]) ⇒ Boolean, msg: ⇒ Any): CommandLineParser[SubCommand]

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to Ensuring[CommandLineParser[SubCommand]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  22. def ensuring(cond: (CommandLineParser[SubCommand]) ⇒ Boolean): CommandLineParser[SubCommand]

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to Ensuring[CommandLineParser[SubCommand]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  23. def ensuring(cond: Boolean, msg: ⇒ Any): CommandLineParser[SubCommand]

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to Ensuring[CommandLineParser[SubCommand]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  24. def ensuring(cond: Boolean): CommandLineParser[SubCommand]

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to Ensuring[CommandLineParser[SubCommand]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  25. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  26. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  27. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  28. def formatShortDescription(description: String): String

    Permalink

    Formats the short description of a tool when printing out the list of sub-commands in the usage.

    Formats the short description of a tool when printing out the list of sub-commands in the usage.

    (1) find the first period (".") and keep only everything before it (2) shorten it to the maximum line length adding "..." to the end.

    Definition Classes
    CommandLineParserStrings
  29. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to StringFormat[CommandLineParser[SubCommand]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  30. def genericClpNameOnCommandLine: String

    Permalink

    The name of "command" on the command line

    The name of "command" on the command line

    Definition Classes
    CommandLineParserStrings
  31. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  32. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  33. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  34. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  35. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  36. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. def parseCommandAndSubCommand[Command](args: Seq[String], subcommands: Traversable[Class[_ <: SubCommand]])(implicit tt: scala.reflect.api.JavaUniverse.TypeTag[Command]): Result[_ <: Command, _ <: SubCommand]

    Permalink

    Method for parsing command arguments as well as a specific sub-command arguments.

    Method for parsing command arguments as well as a specific sub-command arguments. Typically, the arguments are the format [command arguments] [sub-command] [sub-command arguments]. This in contrast to parseSubCommand, which omits the [command arguments] section.

    (1) Searches for -- or a recognized SubCommand in the list of arguments to partition the main and clp arguments. The SubCommands are found by searching for all classes that extend SubCommand. (2) Parses the main arguments and creates an instance of main, and returns None if any error occurred. (3) Executes the afterMainBuilding of code after the main instance has been created. (3) Parses the clp arguments and creates an instance of clp, and returns None if any error occurred. (3) Executes the afterClpBuilding of code after the clp instance has been created.

    It creates CommandLineProgramParsers to parse the main class and clp arguments respectively.

    args

    the command line arguments to parse.

    subcommands

    the set of available sub-commands

    returns

    the Command and SubCommand instances initialized with the command line arguments, or None if unsuccessful.

  38. def parseSubCommand(args: Seq[String], subcommands: Traversable[Class[_ <: SubCommand]], withVersion: Boolean = true, withSpecialArgs: Boolean = true, extraUsage: Option[String] = None): Result[_ <: SubCommand, Nothing]

    Permalink

    The main method for parsing command line arguments.

    The main method for parsing command line arguments. Typically, the arguments are the format [clp Name] [clp arguments]. This in contrast to parseCommandAndSubCommand, which includes arguments to the main class in the [main arguments] section.

    (1) Finds all classes that extend SubCommand to include them as valid command line programs on the command line. (2) When the first arg is one of the command line programs names (usually getSimpleName), it creates a CommandLineProgramParser (SubCommand parser) for the given command line program, and allows the SubCommand parser to parse the rest of the args. (3) Returns None in the case of any parsing error, or an instance of the command line program constructed according to the parsed arguments.

    args

    the command line arguments to parse.

    subcommands

    the set of possible sub-command types/classes

    withVersion

    true to print the version in the usage messages, false otherwise.

    withSpecialArgs

    if true include help and version arguments

    extraUsage

    an optional string that will be printed prior to any usage message.

    returns

    a clp instance initialized with the command line arguments, or None if unsuccessful.

  39. def standardCommandAndSubCommandUsagePreamble(commandClazz: Option[Class[_]] = None, subCommandClazz: Option[Class[_]] = None): String

    Permalink

    A typical command line program will call this to get the beginning of the usage message, and then append a description of the program.

    A typical command line program will call this to get the beginning of the usage message, and then append a description of the program.

    Definition Classes
    CommandLineParserStrings
  40. def standardSubCommandUsagePreamble(clazz: Option[Class[_]] = None): String

    Permalink

    A typical command line program will call this to get the beginning of the usage message, and then append a description of the program.

    A typical command line program will call this to get the beginning of the usage message, and then append a description of the program.

    Definition Classes
    CommandLineParserStrings
  41. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  42. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  43. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. def [B](y: B): (CommandLineParser[SubCommand], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from CommandLineParser[SubCommand] to ArrowAssoc[CommandLineParser[SubCommand]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from CommandLineParserStrings

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from CommandLineParser[SubCommand] to any2stringadd[CommandLineParser[SubCommand]]

Inherited by implicit conversion StringFormat from CommandLineParser[SubCommand] to StringFormat[CommandLineParser[SubCommand]]

Inherited by implicit conversion Ensuring from CommandLineParser[SubCommand] to Ensuring[CommandLineParser[SubCommand]]

Inherited by implicit conversion ArrowAssoc from CommandLineParser[SubCommand] to ArrowAssoc[CommandLineParser[SubCommand]]

Ungrouped