Expand description
A command line parser
Project
- Repository: https://bitbucket.org/haibison/dia-args
- License: Nice License 1.0.1 (see LICENSE file at root directory of main branch)
- This project follows Semantic Versioning 2.0.0
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 withhelp
command for more details.
Specification 0.0.1
A program argument can be:
- A command.
- An argument.
- An option.
- Two special phrases:
-
and--
.
-
Commands
- A command can be anything which does not start with either
-
or--
.
- A command can be anything which does not start with either
-
Arguments
- Same as a command, an argument can be anything which does not start with either
-
or--
.
- Same as a command, an argument can be anything which does not start with either
-
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.
- An equals sign
-
A boolean option has 2 values:
true
andfalse
. The value is optional. If absent,true
will be assigned.
-
-
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.
-
Passing arguments to a program
Must be in this form:
program [command|arguments...|options...|-] [-- [arguments...]]
in which:
[]
means optional....
means multiple arguments.
Modules
Macros
Makes a vector of Cow<'_, Cmd<'_>>
from a list of either Cmd
or &Cmd
Makes a vector of Cow<'_, Option<'_>>
from a list of either Option
or &Option
Structs
Arguments
Enums
Answer
Merge option
Constants
Crate code name
Description of argument file format, in English
Default file name for storing arguments: .dia-args
false
as string
ID of this crate
Maximum size allowed for argument file to be parsed (3 MiB)
Crate name
Crate release date (year/month/day)
Tag, which can be used for logging…
true
as string
Crate version
Functions
Asks user some question
Locks stderr and writes to it
Locks stdout and writes to it
Parses from process’ arguments
Parses from file
Parses a stream of strings, separated by null byte (0
)
Parses from an iterator of strings
Reads a line from stdin, trims and converts it to T
Type Definitions
Result type used in this crate