Type Aliases

type alias OptionDescr[a: Type] = { argDescriptor = ArgDescr[a], explanation = String, optionIds = List[Char], optionNames = List[String] } Source

An OptionDescr describes a single command line option.

  • optionIds is a list of single character abbreviations identifying the option
  • optionNames is a list of long names identifying the option
  • argDescriptor defines the format of the option
  • explanation is the description of the option printed to the user by the function usageInfo


def getOpt(ordering: ArgOrder[a], optDescriptors: List[OptionDescr[a]], sourceArgs: List[String]): Validation[String, { nonOptions = List[String], options = List[a] }] Source

Decode the list of command line options supplied to the program.

ordering mandates how processing of options and non-options is handled.

optDescriptors is a list of processors for decoding individual options.

sourceArgs should be the list of command line arguments supplied to the program.

If successful, getOpt returns lists of decoded options and non-options. If unsuccessful it returns a non-empty list of error messages, with unknown options considered to be errors.

def getOpt1(ordering: ArgOrder[a], optDescriptors: List[OptionDescr[a]], sourceArgs: List[String]): { errors = List[String], nonOptions = List[String], options = List[a], unknowns = List[String] } Source

This is a more general version of getOpt that returns all the results of decoding the command line options without distinguishing whether the decoding is successful or a failure.

Client code calling this function, rather than getOpt, is free to process or ignore the results collected in unknowns and errors which would indicate problems with the decoding if either were not empty.

def preprocess(options: { quoteClose = String, quoteOpen = String, stripQuoteMarks = Bool }, args: List[String]): List[String] Source

Preprocessing the commandline args.

Preprocess the command line arguments before parsing them.

Arguments supplied as an List[String] to the program are simply derived from the input split on space. This does not account for, for example, Windows file names which may include space.

preprocess is a simple function that can be used to "rejoin" command line arguments if they were joined by "quotation marks" in the user supplied string (quotations marks are configurable and do not have to be double quotes).

def usageInfo(header: String, optionDescriptors: List[OptionDescr[a]]): String Source

Return a formatted string describing the usage of the command.

Typically this output is used by "--help"