clap-nested
A convenient clap
setup for multi-level CLI subcommands.
Installation
Add clap-nested
to your Cargo.toml
:
[]
= "0.2.0"
Why?
First of all, clap
is awesome!
It provides a fast, simple-to-use, and full-featured library for parsing CLI arguments as well as subcommands.
However, while supporting parsing nicely, clap
is very unopinionated
when it comes to how we should structure and execute logic given provided
arguments and subcommands.
That's why we often find ourselves matching clap
's parsing result with
tens of subcommands, let alone a lot of arguments, in our CLI application which
includes multi-level subcommands. The bad experience also escalates quickly,
imagine suddenly we have a lot of subcommand logic grouped under a very long
file.
So, we add a little sauce of opinion into clap
to help with that
awkward process.
Usage
With clap-nested
, we can write it in a more organized way:
// foo.rs
// bar.rs
// main.rs
Kindly see examples/clap_nested/
and examples/clap.rs
for comparison.