diff --git a/index.js b/index.js index cc840cd81..c7d3630ff 100644 --- a/index.js +++ b/index.js @@ -316,17 +316,17 @@ class Help { * @param {string} str * @param {number} width * @param {number} indent + * @param {number} [minColumnWidth=40] * @return {string} * */ - wrap(str, width, indent) { + wrap(str, width, indent, minColumnWidth = 40) { // Detect manually wrapped and indented strings by searching for line breaks // followed by multiple spaces/tabs. if (str.match(/[\n]\s+/)) return str; // Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line). const columnWidth = width - indent; - const minColumnWidth = 40; if (columnWidth < minColumnWidth) return str; const leadingStr = str.substr(0, indent); diff --git a/typings/index.d.ts b/typings/index.d.ts index d2c383459..37389a4f2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -121,7 +121,7 @@ declare namespace commander { * Wrap the given string to width characters per line, with lines after the first indented. * Do not wrap if insufficient room for wrapping, or string is manually formatted. */ - wrap(str: string, width: number, indent: number): string; + wrap(str: string, width: number, indent: number, minColumnWidth?: number): string; /** Generate the built-in help text. */ formatHelp(cmd: Command, helper: Help): string;