clipanion
Advanced tools
Comparing version 3.2.0-rc.3 to 3.2.0-rc.4
@@ -97,2 +97,8 @@ /// <reference types="node" /> | ||
/** | ||
* Returns a rich color format if colors are enabled, or a plain text format otherwise. | ||
* | ||
* @param colored Forcefully enable or disable colors. | ||
*/ | ||
format(colored?: boolean): ColorFormat; | ||
/** | ||
* Compiles a command and its arguments using the `CommandBuilder`. | ||
@@ -196,2 +202,3 @@ * | ||
}): string; | ||
format(colored?: boolean): ColorFormat; | ||
protected getUsageByRegistration(klass: CommandClass<Context>, opts?: { | ||
@@ -219,4 +226,3 @@ detailed?: boolean; | ||
}; | ||
protected format(colored: boolean | undefined): ColorFormat; | ||
} | ||
export {}; |
@@ -139,2 +139,3 @@ 'use strict'; | ||
error: (error, opts) => this.error(error, opts), | ||
format: colored => this.format(colored), | ||
process: input => this.process(input), | ||
@@ -348,2 +349,6 @@ run: (input, subContext) => this.run(input, { ...context, ...subContext }), | ||
} | ||
format(colored) { | ||
var _a; | ||
return ((_a = colored !== null && colored !== void 0 ? colored : this.enableColors) !== null && _a !== void 0 ? _a : Cli.defaultContext.colorDepth > 1) ? format.richFormat : format.textFormat; | ||
} | ||
getUsageByRegistration(klass, opts) { | ||
@@ -358,6 +363,2 @@ const record = this.registrations.get(klass); | ||
} | ||
format(colored) { | ||
var _a; | ||
return ((_a = colored !== null && colored !== void 0 ? colored : this.enableColors) !== null && _a !== void 0 ? _a : Cli.defaultContext.colorDepth > 1) ? format.richFormat : format.textFormat; | ||
} | ||
} | ||
@@ -364,0 +365,0 @@ /** |
@@ -5,3 +5,4 @@ export { Command } from './Command'; | ||
export { UsageError, ErrorMeta, ErrorWithMeta } from '../errors'; | ||
export { formatMarkdownish, ColorFormat } from '../format'; | ||
export * as Builtins from './builtins'; | ||
export * as Option from './options'; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var Command = require('./Command.js'); | ||
var format = require('../format.js'); | ||
var Cli = require('./Cli.js'); | ||
@@ -16,4 +17,5 @@ var index = require('./builtins/index.js'); | ||
exports.Command = Command.Command; | ||
exports.formatMarkdownish = format.formatMarkdownish; | ||
exports.Cli = Cli.Cli; | ||
exports.Builtins = index; | ||
exports.Option = index$1; |
@@ -9,2 +9,9 @@ export interface ColorFormat { | ||
export declare const textFormat: ColorFormat; | ||
/** | ||
* Formats markdown text to be displayed to the console. Not all markdown features are supported. | ||
* | ||
* @param text The markdown text to format. | ||
* @param opts.format The format to use. | ||
* @param opts.paragraphs Whether to cut the text into paragraphs of 80 characters at most. | ||
*/ | ||
export declare function formatMarkdownish(text: string, { format, paragraphs }: { | ||
@@ -11,0 +18,0 @@ format: ColorFormat; |
@@ -29,2 +29,9 @@ 'use strict'; | ||
} | ||
/** | ||
* Formats markdown text to be displayed to the console. Not all markdown features are supported. | ||
* | ||
* @param text The markdown text to format. | ||
* @param opts.format The format to use. | ||
* @param opts.paragraphs Whether to cut the text into paragraphs of 80 characters at most. | ||
*/ | ||
function formatMarkdownish(text, { format, paragraphs }) { | ||
@@ -59,3 +66,3 @@ // Enforce \n as newline character | ||
}); | ||
// Highlight the code segments | ||
// Highlight the bold segments | ||
text = text.replace(/(\*\*)((?:.|[\n])*?)\1/g, ($0, $1, $2) => { | ||
@@ -62,0 +69,0 @@ return format.bold($1 + $2 + $1); |
{ | ||
"name": "clipanion", | ||
"version": "3.2.0-rc.3", | ||
"version": "3.2.0-rc.4", | ||
"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
Sorry, the diff of this file is not supported yet
206906
4872