Crate dia_args

source ·
Expand description

A command line parser

Project

Features

  • TODO

Specification 0.0.1

A program argument can be:

  • A command.
  • An argument.
  • An option.
  • Two special phrases: - and --.
  1. Commands

    • Form: [a-zA-Z][a-zA-Z0-9\-]*[^\-]?
  2. Arguments

    • An argument can be anything which does not start with either - or --.
  3. Options

    An option starts with - or --.

    • - supports either:

      • A single short format option.
      • Or multiple short format boolean options.
    • -- supports a single long format option.

    • Option values can be anything.

    • An option’s key and value can be separated by either:

      • An equals sign =.
      • Or mutiple white spaces.
    • A boolean option has 2 values: true and false. The value is optional. If absent, true will be assigned.

  4. Special phrases

    • - means: the program should process standard input.
    • -- means: the program should process all arguments after it as arguments.
  5. Passing arguments to a program

    Must be in this form:

    program [command] [arguments...] [options...] [-] [-- [arguments...]]

    in which:

    • [] means optional.
    • ... means multiple arguments.

Structs

Arguments

Constants

Crate code name
false as string
Crate name
Crate release date (year/month/day)
Tag, which can be used for logging…
true as string
Unique universally identifier of this crate
Crate version

Functions

Parses from process’ arguments
Parses from an iterator of strings