These are chat archives for kbknapp/clap-rs

7th
Jun 2016
Brian Pearce
@brianp
Jun 07 2016 20:09
Hey! Thanks for clap!
I did have a questions around SubCommands and expectations.
Kevin K.
@kbknapp
Jun 07 2016 20:10
Sure! What's the question? :)
Brian Pearce
@brianp
Jun 07 2016 20:10
If the main execution of a cl app is "myapp <file>" and file is normally required. That means when I add a SubCommand of "new" the syntax is "myapp <file> new [args]"
Where really, what I want is <file> to only be required, if I'm not running a subcommand
Ideally the subcommand would be "myapp new <file>"
So I'm just wondering if I'm thinking about this wrong, or if there is a best practice I'm unaware of to make the required args of the initial command, also required in the subcommands.
Kevin K.
@kbknapp
Jun 07 2016 20:13
I'm on mobile so I can't link to the docs but what you need is AppSettings:: SubcommandsNegateReqirements
Brian Pearce
@brianp
Jun 07 2016 20:13
Ahhhh someone has run in to a similar situation :)
cool I'll browse the docs for it and am sure I'll find it. Thanks for mentioning it!
Kevin K.
@kbknapp
Jun 07 2016 20:14
It does exactly that, makes those required args only required when no subcommands are present
Yep! :)
Brian Pearce
@brianp
Jun 07 2016 20:14
As far as best practice goes though, is that an anti-pattern? To un require required opts?
Or is this the more expected outcome?
(I'm new to writing cl tools)
Kevin K.
@kbknapp
Jun 07 2016 20:15
No that's a normal pattern
Brian Pearce
@brianp
Jun 07 2016 20:15
Cool, thanks for the clarification, and doc ref!
Kevin K.
@kbknapp
Jun 07 2016 20:16
No prob!
Brian Pearce
@brianp
Jun 07 2016 20:16
Given the chance I'm going to skim through the issues and see if theres anything "easyish" I can help out on/fix sometime soon
Kevin K.
@kbknapp
Jun 07 2016 20:17
Awesome! If you want to tackle something but aren't sure where/how to start just ask. I'm always happy to mentor new contributors
Thats the docs page for that setting you need
Brian Pearce
@brianp
Jun 07 2016 20:24
Awesome! Thanks. I got distracted and hadn't looked it up yet :+1: