From f6c5df932dfba1567ef8b521796ecaf73317638d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 16 Jan 2023 20:13:49 -0400 Subject: padding lines between long option help --- src/upd8.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/upd8.js b/src/upd8.js index 5668542c..42f0df46 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -252,6 +252,8 @@ async function main() { console.log(`(No options available)`) } + let justInsertedPaddingLine = false; + for (const {name, descriptor} of sortedOptions) { if (descriptor.alias) { continue; @@ -261,6 +263,16 @@ async function main() { .filter(([_name, {alias}]) => alias === name) .map(([name]) => name); + let wrappedHelp, wrappedHelpLines = 0; + if (descriptor.help) { + wrappedHelp = indentWrap(4, descriptor.help); + wrappedHelpLines = wrappedHelp.split('\n').length; + } + + if (wrappedHelpLines > 1 && !justInsertedPaddingLine) { + console.log(''); + } + console.log(color.bright(` --` + name) + (aliases.length ? ` (or: ${aliases.map(alias => color.bright(`--` + alias)).join(', ')})` @@ -269,12 +281,21 @@ async function main() { ? '' : color.dim(' (no help provided)'))); - if (descriptor.help) { - console.log(indentWrap(4, descriptor.help)); + if (wrappedHelp) { + console.log(wrappedHelp); + } + + if (wrappedHelpLines > 1) { + console.log(''); + justInsertedPaddingLine = true; + } else { + justInsertedPaddingLine = false; } } - console.log(``); + if (!justInsertedPaddingLine) { + console.log(``); + } }; console.log( -- cgit 1.3.0-6-gf8a5