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

Change options sort #191 #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/help/__tests__/help.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ describe("help", () => {
return expect(strip(await getHelp(prog))).toMatchSnapshot()
})

it("should display help for a program with options in order given", async () => {
prog
.argument("<foo>", "Mandarory foo arg")
.argument("[other]", "Other args")
.option("-f, --file <file>", " Output file")
.option("-e, --ext <extension>", " extension file")
return expect(strip(await getHelp(prog))).toMatchSnapshot()
})


it("should display help for a program having at least one command (with args & options)", async () => {
prog
.command("test-command", "Test command")
Expand Down
2 changes: 1 addition & 1 deletion src/help/templates/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import sortBy from "lodash/sortBy"
export const command: Template = async (ctx: TemplateContext) => {
const { cmd, globalOptions: globalFlags, eol, eol3, colorize, tpl } = ctx

const options = sortBy(cmd!.options, "name"),
const options = sortBy(cmd!.options, "required"),
globalOptions = Array.from(globalFlags.keys())

const help =
Expand Down