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

fix(usage): tie usage to config #2908

Merged
merged 1 commit into from
Mar 22, 2021
Merged

Conversation

wraithgar
Copy link
Member

@wraithgar wraithgar commented Mar 19, 2021

This starts us down the path of tying the params our commands accept to
their config items. For now it is optional, and not every current
config item would cleanly render if we added them today.

The ones that are added here DO render nicely, and we can iterate from
here. We can also at a later date do the same kind of appraoch with our
positional args.

References

Related to npm/statusboard#308

Here we can see the brute-force "Just show a really long complicated usage string" approach for our current save-flag situation in use.
Screen Shot 2021-03-19 at 2 12 45 PM

@scope hint example
Screen Shot 2021-03-19 at 2 13 24 PM

Shorthand examples
Screen Shot 2021-03-19 at 2 13 32 PM

Example of using manual usage declaration in the config to show the --no- option instead
Screen Shot 2021-03-19 at 2 14 04 PM

@wraithgar wraithgar requested a review from a team as a code owner March 19, 2021 19:00
@wraithgar wraithgar force-pushed the gar/usage-from-config branch 2 times, most recently from c4145cd to 2c3c747 Compare March 19, 2021 21:10
@@ -1311,6 +1313,34 @@ The program to use to view help content.

Set to `"browser"` to view html help content in the default web browser.

#### `which`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which was not defined yet, and I re-ran the make to generate this file. We should think about automating this make command

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's included in the make docs that's part of the release process as a final safety net, but some easier way to run it ahead of time would be nice, too, I agree.

@@ -21,6 +21,8 @@ t.test('basic definition', async t => {
default: 'some default value',
defaultDescription: '"some default value"',
type: [Number, String],
hint: '<key>',
usage: '--key <key>|--key <key>',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can address this once we add a config item that has this kind of type to a command's params.

@wraithgar wraithgar added semver:patch semver patch level for changes Release 7.x work is associated with a specific npm 7 release release: next These items should be addressed in the next release labels Mar 22, 2021
Copy link
Contributor

@nlf nlf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love this. generated usage information based on the actual available options is a huge win. added bonus that we're now separating options that are available from usage information, which are indeed two separate concerns

Copy link
Contributor

@isaacs isaacs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this. A few suggestions and minor nitpicky fixups, but overall this is exactly the direction we should be going, yes.

@@ -1311,6 +1313,34 @@ The program to use to view help content.

Set to `"browser"` to view html help content in the default web browser.

#### `which`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's included in the make docs that's part of the release process as a final safety net, but some easier way to run it ahead of time would be nice, too, I agree.

lib/pack.js Outdated Show resolved Hide resolved
lib/pack.js Outdated Show resolved Hide resolved
lib/fund.js Outdated Show resolved Hide resolved
lib/uninstall.js Outdated Show resolved Hide resolved
@wraithgar wraithgar force-pushed the gar/usage-from-config branch 2 times, most recently from 8a7855e to f37bb68 Compare March 22, 2021 17:08
This starts us down the path of tying the params our commands accept to
their config items.  For now it is optional, and not every current
config item would cleanly render if we added them today.

The ones that are added here DO render nicely, and we can iterate from
here.  We can also at a later date do the same kind of appraoch with our
positional args.

PR-URL: #2908
Credit: @wraithgar
Close: #2908
Reviewed-by: @nlf, @isaacs
@wraithgar wraithgar merged commit b876442 into release-next Mar 22, 2021
@wraithgar wraithgar deleted the gar/usage-from-config branch November 2, 2021 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: next These items should be addressed in the next release Release 7.x work is associated with a specific npm 7 release semver:patch semver patch level for changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants