3 releases
Uses new Rust 2024
| 0.0.3 | Sep 21, 2025 |
|---|---|
| 0.0.2 | Sep 20, 2025 |
| 0.0.1 | Sep 1, 2025 |
#920 in Command-line interface
101 downloads per month
37KB
819 lines
lahl: lightweight-argument-handling-library
Provides
- Defining the structure of a command-line program
- Help / usage message generation
- Non-macro based API
Features
- endpoint grouping, e.g
*program* experimental build *args*(two specifiers for name) - multiple for named and positional arguments
Key ideas
- CLI defined by
'staticslices - An endpoint is a section of a CLI. Specified by 1-2 initial arguments
- An endpoint can have named and positional parameters
- At runtime a
Iterator<Item=String>of is parsed to a program and it returns a structure containing parameter argument pairings - Very little validation is done, it is upto the user to check required parameters are present and strings are parsed into their required forms
Linting
During runtime the definition is not checked. Therefore it can have multiple problems
- Invalid endpoint or argument name. e.g. empty or contains whitespace
- Positional parameter after positional parameter accepting multiple (unreachable)
To catch these errors you can run CLI::lint as a test
Future
- Run
lintondebug_assertions? - Lifetime on
CLI(rather than'static) - More checking in this library
struct+ derive-macro API withFromStringlogic- Shorthand named parameter
- Auto-completion generation for shells (Powershell, Bash, Fish etc)
- JavaScript library that mirrors Rust API
- Replace
HashSetin unique lookup?