Skip to content

Commit

Permalink
fix: show docs for allowNo on boolean flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Sep 1, 2018
1 parent bf8e350 commit 208a27a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"wrap-ansi": "^4.0.0"
},
"devDependencies": {
"@oclif/config": "^1.7.3",
"@oclif/config": "^1.7.4",
"@oclif/dev-cli": "^1.17.0",
"@oclif/errors": "^1.2.0",
"@oclif/plugin-legacy": "^1.1.0",
Expand Down
8 changes: 7 additions & 1 deletion src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ export default class CommandHelp {
let body = renderList(flags.map(flag => {
const label = []
if (flag.char) label.push(`-${flag.char[0]}`)
if (flag.name) label.push(`--${flag.name.trim()}`)
if (flag.name) {
if (flag.type === 'boolean' && flag.allowNo) {
label.push(`--[no-]${flag.name.trim()}`)
} else {
label.push(`--${flag.name.trim()}`)
}
}
let left = label.join(', ')
if (flag.type === 'option') {
let value = flag.helpValue || flag.name
Expand Down
13 changes: 13 additions & 0 deletions test/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ OPTIONS
ARGUMENTS
ARG1 (option1|option2) Show the options`))

test
.commandHelp(class extends Command {
static id = 'apps:create'
static flags = {
opt: flags.boolean({allowNo: true})
}
})
.it('outputs with possible options', ctx => expect(ctx.commandHelp).to.equal(`USAGE
$ oclif apps:create
OPTIONS
--[no-]opt`))

// class AppsCreate3 extends Command {
// static id = 'apps:create'
// static flags = {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
debug "^3.1.0"
semver "^5.5.0"

"@oclif/config@^1.7.0", "@oclif/config@^1.7.3":
version "1.7.3"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.7.3.tgz#b666b581a9b080419d5f12a2cb618a2c4c6bced0"
"@oclif/config@^1.7.0", "@oclif/config@^1.7.4":
version "1.7.4"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.7.4.tgz#5b7f779534a339de8c62a863b12f5740b15c41f5"
dependencies:
debug "^3.1.0"
tslib "^1.9.3"
Expand Down Expand Up @@ -109,8 +109,8 @@
resolved "https://registry.yarnpkg.com/@oclif/linewrap/-/linewrap-1.0.0.tgz#aedcb64b479d4db7be24196384897b5000901d91"

"@oclif/parser@^3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@oclif/parser/-/parser-3.6.0.tgz#8d0b4c3e012aa1f0d59a6936b3dedec318b11a6d"
version "3.6.1"
resolved "https://registry.yarnpkg.com/@oclif/parser/-/parser-3.6.1.tgz#dd0ad29d9178d75a2de30314874a6167675925ed"
dependencies:
"@oclif/linewrap" "^1.0.0"
chalk "^2.4.1"
Expand Down

0 comments on commit 208a27a

Please sign in to comment.