72 releases (breaking)

0.54.1 May 1, 2021
0.54.0 Mar 19, 2021
0.53.1 Mar 18, 2021
0.51.6 Dec 6, 2019
0.0.4 May 15, 2018

#106 in Command-line interface

Download history 61/week @ 2021-02-22 38/week @ 2021-03-01 21/week @ 2021-03-08 58/week @ 2021-03-15 225/week @ 2021-03-22 151/week @ 2021-03-29 96/week @ 2021-04-05 180/week @ 2021-04-12 186/week @ 2021-04-19 40/week @ 2021-04-26 20/week @ 2021-05-03 15/week @ 2021-05-10 82/week @ 2021-05-17 30/week @ 2021-05-24 13/week @ 2021-05-31 92/week @ 2021-06-07

430 downloads per month
Used in less than 12 crates

Custom license

99KB
1.5K SLoC

Dia-args




lib.rs:

A command line parser

Project

Features

  • No debts: no dependencies. It's an argument parser, so standard Rust is enough.
  • There's a specification (below). It has a separate version, not same as the library's.
  • parse_file() helps parse arguments stored in your file.
  • ::docs helps make documentation for your program.
  • Optional bin feature provides a program which helps you generate simple Rust source code templates. You can run the program with help command for more details.

Specification 0.0.1

A program argument can be:

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

    • A command can be anything which does not start with either - or --.
  2. Arguments

    • Same as a command, 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 phrases after it as arguments. This is normally used to pass arguments to sub process.
  5. Passing arguments to a program

    Must be in this form:

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

    in which:

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

Dependencies