Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default values to --help output #39

Merged
merged 4 commits into from
Nov 14, 2016
Merged

Conversation

TooTallNate
Copy link
Collaborator

Fixes #38.

I also fixed a bug with Boolean types showing undefined in the output.

Before:

    -b, --b undefined  a boolean type
    -l, --l <list>     a list type
    -n, --n <n>        a number type
    -o, --o            no default value
    -s, --s [value]    a string type

Now:

    -b, --b          a boolean type (defaults to true)
    -l, --l <list>   a list type (defaults to [1,2,3])
    -n, --n <n>      a number type (defaults to 42)
    -o, --o          no default value
    -s, --s [value]  a string type (defaults to "milk")

Thought: for bool types we could say "on" or "enabled" (and "off" or "disabled")
instead of true/false to make the output a little bit more human-friendly.

@leo
Copy link
Owner

leo commented Nov 2, 2016

Thanks! Exactly, I'd say "Disabled by default" and "enabled by default". But only if the user passed a default bool value.

We don't want to include it in the `--help` output
as a default value.
@leo
Copy link
Owner

leo commented Nov 14, 2016

@TooTallNate You removed the default value for -v. Have you checked if running <cmd> -v and <cmd> --version still returns the version of the app?

@leo leo self-assigned this Nov 14, 2016
@TooTallNate
Copy link
Collaborator Author

Yes, -v / --version still work as expected because of

args/src/index.js

Lines 339 to 344 in f838e16

// And immediately output it if used in command line
if (this.raw.v || this.raw.version) {
console.log(version)
process.exit()
}
}
.

Removing the default value just removed it from the help output ("defaults to v1.0.0" doesn't make much sense).

@leo leo changed the title add default values to --help output Add default values to --help output Nov 14, 2016
@leo
Copy link
Owner

leo commented Nov 14, 2016

@TooTallNate Great, thanks! ❤️ I have also added you as a collaborator.

@leo leo merged commit 74c4093 into leo:master Nov 14, 2016
@TooTallNate TooTallNate deleted the add/help-defaults branch November 14, 2016 18:03
leo added a commit that referenced this pull request May 1, 2022
* add default values to `--help` output

Fixes #38.

* fix `xo` lint

* don't set a default value for `--version`

We don't want to include it in the `--help` output
as a default value.

* use enabled/disabled for boolean default values

In --help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--help output should include default values
2 participants