-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: move ctor for command help class to its own function #244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,8 @@ export class Help extends HelpBase { | |
} | ||
|
||
public async showHelp(argv: string[]) { | ||
argv = argv.filter(arg => !getHelpFlagAdditions(this.config).includes(arg)) | ||
|
||
if (this.config.topicSeparator !== ':') argv = standardizeIDFromArgv(argv, this.config) | ||
const subject = getHelpSubject(argv, this.config) | ||
if (!subject) { | ||
|
@@ -202,10 +204,14 @@ export class Help extends HelpBase { | |
command.id = command.id.replace(/:/g, this.config.topicSeparator) | ||
command.aliases = command.aliases && command.aliases.map(a => a.replace(/:/g, this.config.topicSeparator)) | ||
} | ||
const help = new this.CommandHelpClass(command, this.config, this.opts) | ||
const help = this.getCommandHelpClass(command) | ||
Comment on lines
-205
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need a whole new method for this if this is the only place it's used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RodEsp This function will be overridden in the custom help class to allow the determination of short help. |
||
return help.generate() | ||
} | ||
|
||
protected getCommandHelpClass(command: Interfaces.Command) { | ||
return new this.CommandHelpClass(command, this.config, this.opts) | ||
} | ||
|
||
protected formatCommands(commands: Interfaces.Command[]): string { | ||
if (commands.length === 0) return '' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,6 @@ export async function run(argv = process.argv.slice(2), options?: Interfaces.Loa | |
|
||
// display help version if applicable | ||
if (helpAddition(argv, config)) { | ||
argv = argv.filter(arg => !getHelpFlagAdditions(config).includes(arg)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. main.ts should not have any knowledge of what showHelp expects in argv, just pass the whole thing as is. |
||
const Help = await loadHelpClass(config) | ||
const help = new Help(config, config.pjson.helpOptions) | ||
peternhale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await help.showHelp(argv) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the stripping of help flags to showHelp from main.ts.
Other function call via showHelp expect the help flags to be removed.