Skip to content

Commit

Permalink
fix: use configured help class in --help (#768)
Browse files Browse the repository at this point in the history
without this change `my-cli command --help` always uses the default help
class.
  • Loading branch information
nigelzor committed Aug 28, 2023
1 parent 0e13bbd commit b6c69f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/flags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {URL} from 'url'
import {Help} from './help'
import {loadHelpClass} from './help'
import {BooleanFlag} from './interfaces'
import {FlagDefinition, OptionFlagDefaults, FlagParser} from './interfaces/parser'
import {dirExists, fileExists} from './util'
Expand Down Expand Up @@ -114,7 +114,8 @@ export const help = (opts: Partial<BooleanFlag<boolean>> = {}): BooleanFlag<void
description: 'Show CLI help.',
...opts,
parse: async (_, cmd) => {
new Help(cmd.config).showHelp(cmd.id ? [cmd.id, ...cmd.argv] : cmd.argv)
const Help = await loadHelpClass(cmd.config)
await new Help(cmd.config, cmd.config.pjson.helpOptions).showHelp(cmd.id ? [cmd.id, ...cmd.argv] : cmd.argv)
cmd.exit(0)
},
})
Expand Down

0 comments on commit b6c69f1

Please sign in to comment.