Comparing version 3.0.0-rc.7 to 3.0.0-rc.8
@@ -49,8 +49,4 @@ 'use strict'; | ||
register(commandClass) { | ||
var _a; | ||
const specs = new Map(); | ||
const builder = this.builder.command(); | ||
const index = builder.cliIndex; | ||
if (typeof commandClass.paths !== `undefined`) | ||
for (const path of commandClass.paths) | ||
builder.addPath(path); | ||
const command = new commandClass(); | ||
@@ -60,2 +56,8 @@ for (const [key, value] of Object.entries(command)) | ||
specs.set(key, value); | ||
const builder = this.builder.command(); | ||
const index = builder.cliIndex; | ||
const paths = (_a = commandClass.paths) !== null && _a !== void 0 ? _a : command.paths; | ||
if (typeof paths !== `undefined`) | ||
for (const path of paths) | ||
builder.addPath(path); | ||
this.registrations.set(commandClass, { specs, builder, index }); | ||
@@ -206,7 +208,7 @@ for (const [key, { definition }] of specs.entries()) | ||
if (hasLabel && hasVersion) | ||
result += `${this.format(colored).bold(`${this.binaryLabel} - ${this.binaryVersion}`)}\n\n`; | ||
result += `${this.format(colored).header(`${this.binaryLabel} - ${this.binaryVersion}`)}\n\n`; | ||
else if (hasLabel) | ||
result += `${this.format(colored).bold(`${this.binaryLabel}`)}\n`; | ||
result += `${this.format(colored).header(`${this.binaryLabel}`)}\n`; | ||
else | ||
result += `${this.format(colored).bold(`${this.binaryVersion}`)}\n`; | ||
result += `${this.format(colored).header(`${this.binaryVersion}`)}\n`; | ||
result += ` ${this.format(colored).bold(prefix)}${this.binaryName} <command>\n`; | ||
@@ -223,5 +225,5 @@ } | ||
? categoryName.trim() | ||
: `Where <command> is one of`; | ||
: `General commands`; | ||
result += `\n`; | ||
result += `${this.format(colored).bold(`${header}:`)}\n`; | ||
result += `${this.format(colored).header(`${header}`)}\n`; | ||
for (const { commandClass, usage } of commands) { | ||
@@ -249,3 +251,3 @@ const doc = commandClass.usage.description || `undocumented`; | ||
if (details !== `` || examples.length > 0) { | ||
result += `${this.format(colored).bold(`Usage:`)}\n`; | ||
result += `${this.format(colored).header(`Usage`)}\n`; | ||
result += `\n`; | ||
@@ -257,3 +259,3 @@ } | ||
result += `\n`; | ||
result += `${format.richFormat.bold(`Options:`)}\n`; | ||
result += `${format.richFormat.header(`Options`)}\n`; | ||
const maxDefinitionLength = options.reduce((length, option) => { | ||
@@ -269,3 +271,3 @@ return Math.max(length, option.definition.length); | ||
result += `\n`; | ||
result += `${this.format(colored).bold(`Details:`)}\n`; | ||
result += `${this.format(colored).header(`Details`)}\n`; | ||
result += `\n`; | ||
@@ -276,3 +278,3 @@ result += format.formatMarkdownish(details, { format: this.format(colored), paragraphs: true }); | ||
result += `\n`; | ||
result += `${this.format(colored).bold(`Examples:`)}\n`; | ||
result += `${this.format(colored).header(`Examples`)}\n`; | ||
for (const [description, example] of examples) { | ||
@@ -279,0 +281,0 @@ result += `\n`; |
@@ -67,2 +67,6 @@ import { LooseTest } from 'typanion'; | ||
/** | ||
* @deprecated Do not use this; prefer the static `paths` property instead. | ||
*/ | ||
paths?: undefined; | ||
/** | ||
* Paths under which the command should be exposed. | ||
@@ -69,0 +73,0 @@ */ |
export interface ColorFormat { | ||
header(str: string): string; | ||
bold(str: string): string; | ||
@@ -3,0 +4,0 @@ error(str: string): string; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const richFormat = { | ||
header: str => `\x1b[1m${str}${str.length < 79 ? ` ${`━`.repeat(79 - str.length)}` : `:`}\x1b[22m`, | ||
bold: str => `\x1b[1m${str}\x1b[22m`, | ||
@@ -12,2 +13,3 @@ error: str => `\x1b[31m\x1b[1m${str}\x1b[22m\x1b[39m`, | ||
const textFormat = { | ||
header: str => str, | ||
bold: str => str, | ||
@@ -14,0 +16,0 @@ error: str => str, |
{ | ||
"name": "clipanion", | ||
"version": "3.0.0-rc.7", | ||
"version": "3.0.0-rc.8", | ||
"main": "lib/advanced/index", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194529
4604