Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
fix: template usage like plugin-help
Browse files Browse the repository at this point in the history
  • Loading branch information
amphro authored and elbandito committed Mar 27, 2019
1 parent 9a6df78 commit 9c9be3d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/commands/readme.ts
Expand Up @@ -131,7 +131,7 @@ USAGE
commands(config: Config.IConfig, commands: Config.Command[]): string {
return [
...commands.map(c => {
let usage = this.commandUsage(c)
let usage = this.commandUsage(config, c)
return `* [\`${config.bin} ${usage}\`](#${slugify.slug(`${config.bin}-${usage}`)})`
}),
'',
Expand All @@ -141,9 +141,9 @@ USAGE

renderCommand(config: Config.IConfig, c: Config.Command): string {
this.debug('rendering command', c.id)
let title = template({config})(c.description || '').trim().split('\n')[0]
let title = template({config, command: c})(c.description || '').trim().split('\n')[0]
const help = new Help(config, {stripAnsi: true, maxWidth: columns})
const header = () => `## \`${config.bin} ${this.commandUsage(c)}\``
const header = () => `## \`${config.bin} ${this.commandUsage(config, c)}\``
return compact([
header(),
title,
Expand Down Expand Up @@ -212,7 +212,7 @@ USAGE
return p
}

private commandUsage(command: Config.Command): string {
private commandUsage(config: Config.IConfig, command: Config.Command): string {
const arg = (arg: Config.Command.Arg) => {
let name = arg.name.toUpperCase()
if (arg.required) return `${name}`
Expand All @@ -227,6 +227,6 @@ USAGE
]).join(' ')
}
let usages = castArray(command.usage)
return usages.length === 0 ? defaultUsage() : usages[0]
return template({config, command})(usages.length === 0 ? defaultUsage() : usages[0])
}
}

0 comments on commit 9c9be3d

Please sign in to comment.