Skip to content

Commit

Permalink
feat: added help command
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 30, 2018
1 parent 94eaf9d commit bc53900
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@commitlint/cli": "^6.0.2",
"@commitlint/config-conventional": "^6.0.2",
"@dxcli/config": "^0.1.39",
"@dxcli/engine": "^0.1.20",
"@dxcli/engine": "^0.1.22",
"@dxcli/test": "^0.9.19",
"@dxcli/tslint": "^0.1.3",
"@types/chai": "^4.1.2",
Expand Down
17 changes: 15 additions & 2 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import Command from '@dxcli/command'
import {IConfig} from '@dxcli/config'
import cli from 'cli-ux'

import Help from '..'

const config: IConfig = global.dxcli.config

export default class HelpCommand extends Command {
static title = `display help for ${config.bin}`
static args = [
{name: 'command', required: false}
]

async run() {
const name = this.flags.name || 'world'
cli.log(`hello ${name}!`)
let id = this.args.command as string
let help = new Help(this.config)
let command = this.config.engine!.findCommand(id, true)
let commandHelp = help.command(command)
cli.info(commandHelp)
}
}
3 changes: 3 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
declare namespace NodeJS {
interface Global {
'columns': number
dxcli: {
config: any
}
}
}
14 changes: 14 additions & 0 deletions test/commands/help.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {expect, test} from '@dxcli/test'

describe('help command', () => {
test
.stdout()
.command(['help', 'help'])
.it('shows help command help', ctx => {
expect(ctx.stdout).to.equal(`display help for dxcli
USAGE
$ dxcli help [COMMAND]
`)
})
})
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
lodash "^4.17.4"
read-pkg "^3.0.0"

"@dxcli/engine@^0.1.20":
version "0.1.20"
resolved "https://registry.yarnpkg.com/@dxcli/engine/-/engine-0.1.20.tgz#d46977ccfe69daaf4e2762276ca8e61f48ee8295"
"@dxcli/engine@^0.1.22":
version "0.1.22"
resolved "https://registry.yarnpkg.com/@dxcli/engine/-/engine-0.1.22.tgz#cf21e914c15cafe0188b426c06954eace921b8c5"
dependencies:
"@dxcli/manifest-file" "^0.1.0"
cli-ux "^3.3.8"
Expand Down

0 comments on commit bc53900

Please sign in to comment.