Conversation
|
Needs testing |
* More compact layout (leo/args#124) * Fix options parsing (leo/args#116) * Updates dependencies * https://github.com/leo/args/releases/tag/5.0.0 * https://github.com/leo/args/releases/tag/4.0.0
There's now a `version` subcommand that's always defined in addition to `help`. We only want to showHelp() if those are the only two defined subcommands.
The commands name `help` and `version` are defined by the args library. Here we get a list of commands that doesn't include those. If there are other subcommands (and we haven't specified one), show a list of them.
e1dc40b to
bfba901
Compare
|
The most obvious advantages for us are the updated dependencies and the more compact layout: Before: After: |
chrean
left a comment
There was a problem hiding this comment.
Looks good, I have only a minor question.
|
|
||
| // Show help if no args passed | ||
| if ( this.details.commands.length > 1 && ! this.sub.length ) { | ||
| if ( !! customCommands.length && ! this.sub.length ) { |
There was a problem hiding this comment.
Why are there two different bang policies here, both on a .length params?
There was a problem hiding this comment.
It's a common Javascript way to cast something to a Boolean. The first casts the value to a Boolean but inverts it so the second one is needed to invert it back.
There was a problem hiding this comment.
I know, I just wanted to know why !! customCommands.length has 2 bangs while ! this.sub.length has only one, thought they were similar.
There was a problem hiding this comment.
We're checking to see if we have custom commands defined (!! customCommands.length; looking for true) and not passing any args (! this.sub.length; looking for false).
I think for clarity, this would be better written as:
if ( customCommands.length > 1
&& this.sub.length === 0 ) {
or take it a step further:
const haveCustomCommands = customCommands.length > 1;
const runningSubcommand = this.sub.length === 0;
if ( haveCustomCommands && ! runningSubcommand ) {
More compact layout (Compact layout leo/args#124)
Fix options parsing (fix(defaults): Process help and version defaults better leo/args#116)
Updates dependencies
https://github.com/leo/args/releases/tag/5.0.0
https://github.com/leo/args/releases/tag/4.0.0