-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render helpstring for incomplete subcommands (#579)
* feature: render helpstring for incomplete subcommands Display a help message when a command with subcommands is run without subcommands.
- Loading branch information
1 parent
1cb7ae2
commit 2f0e59b
Showing
4 changed files
with
232 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
feat: Incomplete subcommands render a help message for that specific subcommand. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getPackageManager } from "../package-manager"; | ||
import { mockConsoleMethods } from "./helpers/mock-console"; | ||
import { runInTempDir } from "./helpers/run-in-tmp"; | ||
import { runWrangler } from "./helpers/run-wrangler"; | ||
import type { PackageManager } from "../package-manager"; | ||
|
||
describe("subcommand implicit help ran on imcomplete command execution", () => { | ||
let mockPackageManager: PackageManager; | ||
runInTempDir(); | ||
|
||
beforeEach(() => { | ||
mockPackageManager = { | ||
cwd: process.cwd(), | ||
// @ts-expect-error we're making a fake package manager here | ||
type: "mockpm", | ||
addDevDeps: jest.fn(), | ||
install: jest.fn(), | ||
}; | ||
(getPackageManager as jest.Mock).mockResolvedValue(mockPackageManager); | ||
}); | ||
|
||
const std = mockConsoleMethods(); | ||
function endEventLoop() { | ||
return new Promise((resolve) => setImmediate(resolve)); | ||
} | ||
it("no subcommand for 'pages' should display a list of available subcommands", async () => { | ||
await runWrangler("pages"); | ||
await endEventLoop(); | ||
expect(std.out).toMatchInlineSnapshot(` | ||
"wrangler pages | ||
⚡️ Configure Cloudflare Pages | ||
Commands: | ||
wrangler pages dev [directory] [-- command] 🧑💻 Develop your full-stack Pages application locally | ||
Flags: | ||
-c, --config Path to .toml configuration file [string] | ||
-h, --help Show help [boolean] | ||
-v, --version Show version number [boolean] | ||
--legacy-env Use legacy environments [boolean]" | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters