| Crates.io | ltnt |
| lib.rs | ltnt |
| version | 2.0.1 |
| created_at | 2024-11-19 19:58:17.763035+00 |
| updated_at | 2025-01-14 07:31:55.103201+00 |
| description | A simple, efficient, and flexible arg parsing library. |
| homepage | |
| repository | https://git.sr.ht/~kyllingene/ltnt |
| max_upload_size | |
| id | 1453811 |
| size | 40,606 |
ltnt is a command-line arguments parsing library. It's a simple, efficient,
and flexible library. See the documentation for full examples, as well as the
/examples directory.
It uses a powerful, but easy, syntax for establishing the structure of your invocation:
ltnt::ltnt! {
// A set of commands
pub enum Root in RootArgs {
~Help, // A default command without arguments
Ls = Ls, // A command with arguments
};
// A set of arguments
#[derive(Debug)]
pub struct Ls {
// An argument with long and short forms and a default value
pub all('a'): bool = false,
// An optional argument that's been renamed
pub in_dir as "in" ?: String,
};
}
It uses a declarative macro, has only one dependency, and avoids unnecessary
allocations. It's also available on no_std (with no-default-features),
though it still requires alloc.
Most of the enforced structure in ltnt is merely in how the macro implements
the core trait (Parsable) for your types. So long as you can implement
Parsable, you can use any types you want. The only hard requirements are that
your type is Sized, and that it can be parsed from a stream of strings with
only one item of lookahead.
In practice, you'll usually be interacting with three "kinds" of parsables: commands, arguments, and values.
In the future, I'd like to add a system for generating documentation from your structure, especially help text. I'd also like to support e.g. completion generators, but I don't intend to write them myself.
I also don't plan to support arbitrary syntaxes, or a builder. The reason for
the latter is because builders require some kind of enforced structure, which I
don't want to force on users. One could, however, implement one on top of ltnt