Skip to content

Commit

Permalink
fix: add showHelp method
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 2, 2018
1 parent 164071d commit 64df8c5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 20 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"bugs": "https://github.com/anycli/plugin-help/issues",
"dependencies": {
"@anycli/command": "^0.3.7",
"@anycli/command": "^0.3.8",
"@anycli/screen": "^0.0.3",
"chalk": "^2.3.0",
"cli-ux": "^3.3.13",
Expand All @@ -24,13 +24,13 @@
"wrap-ansi": "^3.0.1"
},
"devDependencies": {
"@anycli/config": "^0.3.0",
"@anycli/config": "^0.3.1",
"@anycli/dev-cli": "^0.1.3",
"@anycli/engine": "^0.3.1",
"@anycli/plugin-help": "^0.4.4",
"@anycli/plugin-plugins": "^0.2.7",
"@anycli/engine": "^0.3.2",
"@anycli/plugin-help": "^0.4.6",
"@anycli/plugin-plugins": "^0.2.8",
"@anycli/plugin-version": "^0.1.30",
"@anycli/test": "^0.10.3",
"@anycli/test": "^0.10.4",
"@anycli/tslint": "^0.2.2",
"@types/chai": "^4.1.2",
"@types/indent-string": "^3.0.0",
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ICachedCommand, IConfig} from '@anycli/config'
import {ICachedCommand, ICommand, IConfig} from '@anycli/config'
import * as screen from '@anycli/screen'
import chalk from 'chalk'
import cli from 'cli-ux'
import indent = require('indent-string')
import * as _ from 'lodash'
import stripAnsi = require('strip-ansi')
Expand Down Expand Up @@ -103,6 +104,14 @@ function renderList(input: (string | undefined)[][], opts: {maxWidth: number, mu
export default class Help {
constructor(public config: IConfig, public opts: HelpOptions = {}) {}

showHelp(command: ICommand, _: string[]) {
if (command.type === 'engine') {
cli.info(this.root())
} else {
cli.info(this.command(command.convertToCached()))
}
}

root(): string {
const help = new RootHelp(this.config, this.opts)
const article = help.root()
Expand Down
58 changes: 45 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
lodash "^4.17.4"
tslib "^1.9.0"

"@anycli/command@^0.3.8":
version "0.3.8"
resolved "https://registry.npmjs.org/@anycli/command/-/command-0.3.8.tgz#25ab49db518b983501661e45d8094aad1f0d0760"
dependencies:
"@anycli/parser" "^3.0.4"
cli-ux "^3.3.13"
debug "^3.1.0"
lodash "^4.17.4"
tslib "^1.9.0"

"@anycli/config@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@anycli/config/-/config-0.3.0.tgz#a0938488e7afc507d69ec13a8e52c71aaecc08ea"
Expand All @@ -23,6 +33,17 @@
lodash "^4.17.4"
read-pkg "^3.0.0"

"@anycli/config@^0.3.1":
version "0.3.1"
resolved "https://registry.npmjs.org/@anycli/config/-/config-0.3.1.tgz#3832c1da47682dd2ba0f9d46117bb5b6513196ef"
dependencies:
cli-ux "^3.3.13"
debug "^3.1.0"
fs-extra "^5.0.0"
load-json-file "^4.0.0"
lodash "^4.17.4"
read-pkg "^3.0.0"

"@anycli/dev-cli@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@anycli/dev-cli/-/dev-cli-0.1.3.tgz#bd3d1229d17c2f61176f872923d4841a539a0cb3"
Expand All @@ -48,11 +69,11 @@
lodash "^4.17.4"
semver "^5.5.0"

"@anycli/engine@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@anycli/engine/-/engine-0.3.1.tgz#c352d9cc73e66759ddc88c72da2907f1e1a0d553"
"@anycli/engine@^0.3.2":
version "0.3.2"
resolved "https://registry.npmjs.org/@anycli/engine/-/engine-0.3.2.tgz#fb8e8d2cf2cd20108ae5fab40b84c3a55cf706ad"
dependencies:
"@anycli/manifest-file" "^0.3.8"
"@anycli/manifest-file" "^0.3.9"
cli-ux "^3.3.13"
debug "^3.1.0"
fs-extra "^5.0.0"
Expand All @@ -71,6 +92,17 @@
lodash "^4.17.4"
proper-lockfile "^3.0.2"

"@anycli/manifest-file@^0.3.9":
version "0.3.9"
resolved "https://registry.npmjs.org/@anycli/manifest-file/-/manifest-file-0.3.9.tgz#d39ab157c0cd9a15471ef8bfd36654c2c4b01730"
dependencies:
cli-ux "^3.3.13"
debug "^3.1.0"
fs-extra "^5.0.0"
load-json-file "^4.0.0"
lodash "^4.17.4"
proper-lockfile "^3.0.2"

"@anycli/parser@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.0.4.tgz#8714c4f73134625fe3781b9e2b5aa0ebb5685a82"
Expand All @@ -93,9 +125,9 @@
widest-line "^2.0.0"
wrap-ansi "^3.0.1"

"@anycli/plugin-help@^0.4.4":
version "0.4.4"
resolved "https://registry.npmjs.org/@anycli/plugin-help/-/plugin-help-0.4.4.tgz#fbddea9c0b1e061ddd684c6ee5ddb15d7c8e4b52"
"@anycli/plugin-help@^0.4.6":
version "0.4.6"
resolved "https://registry.npmjs.org/@anycli/plugin-help/-/plugin-help-0.4.6.tgz#672a96550203968118b881fcdf8f2c685a784bf6"
dependencies:
"@anycli/command" "^0.3.7"
"@anycli/screen" "^0.0.3"
Expand All @@ -116,9 +148,9 @@
cli-ux "^3.3.12"
string-similarity "^1.2.0"

"@anycli/plugin-plugins@^0.2.7":
version "0.2.7"
resolved "https://registry.npmjs.org/@anycli/plugin-plugins/-/plugin-plugins-0.2.7.tgz#b644a3e25424051e819038e2ba87e2b088499785"
"@anycli/plugin-plugins@^0.2.8":
version "0.2.8"
resolved "https://registry.npmjs.org/@anycli/plugin-plugins/-/plugin-plugins-0.2.8.tgz#c143846a528d42abe017298d2360974f8ee7092f"
dependencies:
"@anycli/command" "^0.3.7"
"@anycli/manifest-file" "^0.3.8"
Expand Down Expand Up @@ -151,9 +183,9 @@
version "0.0.3"
resolved "https://registry.yarnpkg.com/@anycli/screen/-/screen-0.0.3.tgz#f0afd970c3ed725702948a45a874ede1fdd9362e"

"@anycli/test@^0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@anycli/test/-/test-0.10.3.tgz#f0179c6407f7a4a71893bd1ded95a0669b20ea31"
"@anycli/test@^0.10.4":
version "0.10.4"
resolved "https://registry.npmjs.org/@anycli/test/-/test-0.10.4.tgz#75575f73b30e99fe6c6b4c3f61fc4928ac4def13"
dependencies:
fancy-test "^0.6.6"
lodash "^4.17.4"
Expand Down

0 comments on commit 64df8c5

Please sign in to comment.