Situation
I want to build a more complex CLI tool. For the purposes of this question, let's say I want to build my own implementation of an AWS Cli tool.
I want to split up the logic in the different services (like EC2, S3, sns, etc) and be able to execute on subcommands.
$ aws ec2 describe-instances
$ aws ec2 start-instances --instance-ids i-1348636c
$ aws s3 <Command> [<Arg> ...]
Complication
To properly split up the business logic, I want to distribute the subcommands over multiple files.
.
├── Cargo.lock
├── Cargo.toml
└── src
├── main.rs
├── S3.rs
├── Ec2.rs
└── etc.rs
I want every service (S3, EC2, etc) to be in control of their own commands and arguments and this would mean that the structure of the subcommands needs to be distributed to the rs files of each the service (S3.rs, Ec2.rs, etc).
Question
What would be the most idiomatic way to create the struct for the args in rust/clap? I prefer to
utilize the #[derive]
macro as much as possible, because it looks like clap is recommending this.