flood-tide
Command line flag and option parse utilities.
Features
no_std
andstd
are supported.- flags, options, subcommand and free arguments
- short flags and options (like
-a
) - long flags and options (like
--long
) - combined short flags (like
-abc
::=-a
-b
-c
) - single long options (like
-long
) - abbreviate long options (like
--abbr
::=--abbreviate
) - single error or multiple errors
- only UTF-8 arguments
- it can be used optimally by a compile switch with many features.
- minimum support rustc 1.56.1 (59eed8a2a 2021-11-01)
Todos
- multiple errors
-
no_std
- option suggestion (do you mean? '--abc')
- windows style (like
/a
) - source code generator support tools
- more easy use
Non-Supports
- procedural macro style
- traditional macro style
- non UTF-8 arguments, multibyte or wide charactor
Examples
in examples directory.
- manual coding style: bsd-sed.rs, gnu-cat.rs
- single long options: ffmpeg.rs
- source code generating by xtask and parse_simple_gnu_style(): curl.rs
Supports
- flood-tide-gen - the generating flood-tide tables
- aki-gsub - the sample used flood-tide
Alternatives
This parser is not a new special idea. It's just comparing characters one by one. Is there anything simpler than this?
- clap - is the most popular and complete one
- structopt - clap parser that uses procedural macros
- gumdrop - a simple parser that uses procedural macros
- argh - procedural macros
- rustop - traditional macro
- pico-args - a simple use
- getopts - a simple use
- docopt - a simple use
Benchmarks
The comparing performance and .text size.
name |
bench |
.text |
Δ bench |
Δ .text |
---|---|---|---|---|
cmp_null_void | 1.213 kc | 342 kib | 0.000 kc | 0 kib |
cmp_flood_tide | 5.439 kc | 386 kib | 4.226 kc | 43 kib |
cmp_gumdrop | 10.686 kc | 456 kib | 9.473 kc | 114 kib |
cmp_pure_rust | 11.052 kc | 390 kib | 9.839 kc | 47 kib |
cmp_argh | 23.644 kc | 429 kib | 22.431 kc | 86 kib |
cmp_pico_args | 152.401 kc | 457 kib | 151.188 kc | 114 kib |
cmp_rustop | 429.309 kc | 497 kib | 428.096 kc | 155 kib |
cmp_clap | 488.611 kc | 925 kib | 487.399 kc | 583 kib |
cmp_getopts | 695.832 kc | 428 kib | 694.620 kc | 85 kib |
cmp_structopt | 697.229 kc | 1083 kib | 696.016 kc | 741 kib |
cmp_commander | 712.974 kc | 437 kib | 711.762 kc | 94 kib |
cmp_lapp | 1113.328 kc | 476 kib | 1112.115 kc | 133 kib |
cmp_args | 2017.061 kc | 489 kib | 2015.848 kc | 146 kib |
cmp_app | 2348.416 kc | 720 kib | 2347.203 kc | 377 kib |
us
is micro seconds.text
is elf .text section sizeΔ
(delta) is the difference from cmp_null_voidcmp_null_void
is non parser, support only--help
and--version
cmp_pure_rust
is newly written with sting match- compile by rustc 1.56.1 (59eed8a2a 2021-11-01)
- bench on intel Q6600 @ 2.40GHz
- refer comparison of various parsers
Changelogs
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.