-
Notifications
You must be signed in to change notification settings - Fork 770
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: display the correct help information when a subcommand is invalid #1052
fix: display the correct help information when a subcommand is invalid #1052
Conversation
Previously, when an invalid subcommand was used, such as `wrangler r2 foo`, the help that was displayed showed the top-level commands prefixed by the command in used. E.g. ``` wrangler r2 init [name] 📥 Create a wrangler.toml configuration file wrangler r2 dev [script] 👂 Start a local server for developing your worker wrangler r2 publish [script] 🆙 Publish your Worker to Cloudflare. ... ``` Now the correct command help is displayed: ``` $ wrangler r2 foo ✘ [ERROR] Unknown argument: foo wrangler r2 📦 Interact with an R2 store Commands: wrangler r2 bucket Manage R2 buckets Flags: -c, --config Path to .toml configuration file [string] -h, --help Show help [boolean] -v, --version Show version number [boolean] ``` Fixes cloudflare#871
🦋 Changeset detectedLatest commit: 270dcc6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Note that a small change, as a result of this fix, is that the help string is now rendered on the stdout rather than stderr stream. The error message itself is still rendered on stderr. |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2345131982/npm-package-wrangler-1052 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1052/npm-package-wrangler-1052 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2345131982/npm-package-wrangler-1052 dev path/to/script.js |
@@ -17,6 +17,33 @@ describe("wrangler", () => { | |||
|
|||
describe("r2", () => { | |||
describe("bucket", () => { | |||
it("should show the correct help when an invalid command is passed", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new test that proves the fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever fix!
Previously, when an invalid subcommand was used, such as
wrangler r2 foo
,the help that was displayed showed the top-level commands prefixed by the command in used.
E.g.
Now the correct command help is displayed:
Fixes #871