mirror of
https://github.com/expo/oclif-plugin-help.git
synced 2026-11-14 19:11:14 -10:00
feat: support src/command/index cmd (#112)
This commit is contained in:
1 parent
a90e317d0f
commit
8957336f3c
1 file changed
+7
-2
+7
-2
@@ -16,6 +16,8 @@ const {
|
||||
bold,
|
||||
} = chalk
|
||||
|
||||
const ROOT_INDEX_CMD_ID = ''
|
||||
|
||||
export interface HelpOptions {
|
||||
all?: boolean;
|
||||
maxWidth: number;
|
||||
@@ -25,8 +27,8 @@ export interface HelpOptions {
|
||||
function getHelpSubject(args: string[]): string | undefined {
|
||||
for (const arg of args) {
|
||||
if (arg === '--') return
|
||||
if (arg.startsWith('-')) continue
|
||||
if (arg === 'help') continue
|
||||
if (arg === 'help' || arg === '--help' || arg === '-h') continue
|
||||
if (arg.startsWith('-')) return
|
||||
return arg
|
||||
}
|
||||
}
|
||||
@@ -99,6 +101,8 @@ export default class Help extends HelpBase {
|
||||
public showHelp(argv: string[]) {
|
||||
const subject = getHelpSubject(argv)
|
||||
if (!subject) {
|
||||
const rootCmd = this.config.findCommand(ROOT_INDEX_CMD_ID)
|
||||
if (rootCmd) this.showCommandHelp(rootCmd)
|
||||
this.showRootHelp()
|
||||
return
|
||||
}
|
||||
@@ -159,6 +163,7 @@ export default class Help extends HelpBase {
|
||||
}
|
||||
|
||||
if (rootCommands.length > 0) {
|
||||
rootCommands = rootCommands.filter(c => c.id)
|
||||
console.log(this.formatCommands(rootCommands))
|
||||
console.log('')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user