Crate dia_args

Source
Expand description

§A command line parser

§Project

  • License: GNU Lesser General Public License, either version 3, or (at your option) any later version.
  • This project follows Semantic Versioning 2.0.0

§Features

  • No debts. It’s an argument parser, so standard Rust is enough.
  • 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

A program argument can be:

  • A command.
  • An argument.
  • An option.
  • A special phrase: --.
  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 a single short format option.

    • -- 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 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.

Modules§

docs
Kit for documentation
licenses
Licenses
paths
Extensions for Args
version_info
0.61.0 (March 24th, 2025)

Macros§

make_cmds
Makes a vector of Cow<'_, Cmd<'_>> from a list of either Cmd or &Cmd
make_options
Makes a vector of Cow<'_, Option<'_>> from a list of either Option or &Option

Structs§

Args
Arguments

Enums§

Answer
Answer
MergeOption
Merge option

Constants§

CODE_NAME
Crate code name
DIA_ARGS_FILE_FORMAT
Description of argument file format, in English
DIA_ARGS_FILE_NAME
Default file name for storing arguments: .dia-args
ID
ID of this crate
MAX_DIA_ARGS_FILE_SIZE
Maximum size allowed for argument file to be parsed (3 MiB)
NAME
Crate name
RELEASE_DATE
Crate release date (year/month/day)
TAG
Tag, which can be used for logging…
VERSION
Crate version

Functions§

ask_user
Asks user some question
lock_write_err
Locks stderr and writes to it
lock_write_out
Locks stdout and writes to it
parse
Parses from process’ arguments
parse_file
Parses from file
parse_stream
Parses a stream of strings, separated by null byte (0)
parse_strings
Parses from an iterator of strings
read_line
Reads a line from stdin, trims and converts it to T

Type Aliases§

Result
Result type used in this crate