Clap: Either do one or all steps

⚓ Rust    📅 2026-01-14    👤 surdeus    👁️ 2      

surdeus

I have a case where I want the command to have multiple steps. I want that if the user specified a single step then do that step but if the user does not specify any then we do all steps.

step1
step2
step3

If I do just progname then we do all 3 steps. However if I do progname step2 then I do only step2.

Currently I have them as booleans. I check if all booleans are false then I set all to true. Wondering if there was something in Clap which can achieve this directly.

If I can do multiple steps as well then that works too. E.g: progname step2 step3, will do the 2 steps and skip step1 but this is nice to have.

2 posts - 2 participants

Read full topic

🏷️ Rust_feed