Crate dia_args[−][src]
A command line parser
Project
- Repository: https://bitbucket.org/haibison/dia-args
- License: Free Public License 1.0.0
- This project follows Semantic Versioning 2.0.0
Features
- TODO
Specification 0.0.1
A program argument can be:
-
A command.
-
An argument.
-
An option.
-
Two special phrases:
-
and--
.
-
Commands
- Form:
[a-zA-Z][a-zA-Z0-9\-]*[^\-]?
- Form:
-
Arguments
- An argument can be anything which does not start with either
-
or--
.
- 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 arguments after it as arguments.
-
Passing arguments to a program
Must be in this form:
program [command] [arguments...] [options...] [-] [-- [arguments...]]
in which:
[]
means optional....
means multiple arguments.
Implementation
The main technique is using macros to generate structs holding options, arguments...
- https://doc.rust-lang.org/book/first-edition/macros.html
- https://doc.rust-lang.org/book/second-edition/appendix-04-macros.html
Notes
-
[
Arg
] takes care of arguments and options. -
Commands should be handled by other functions/structs...
-
In code (not in command line), the user can provide mixed arguments/options in any arbitrary order. The parser(s) should re-arrange them to parse.
-
TODO
Structs
Args |
Arguments |
Constants
CODE_NAME |
Crate code name |
FALSE_AS_STRING |
|
NAME |
Crate name |
RELEASE_DATE |
Crate release date (year/month/day) |
TAG |
Tag, which can be used for logging... |
TRUE_AS_STRING |
|
UUID |
Unique universally identifier of this crate |
VERSION |
Crate version |
Functions
parse |
Parses from process' arguments |
parse_from |
Parses from an iterator of strings |