From 5fc12d16a0bc2c06f9c6c8ab5a3b8aecf9270cb2 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 4 Apr 2024 16:42:18 +0100 Subject: [PATCH] help: Wrap more of the command-usage text --- src/puter-shell/coreutils/coreutil_lib/help.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/puter-shell/coreutils/coreutil_lib/help.js b/src/puter-shell/coreutils/coreutil_lib/help.js index 2cdb526..fbf16f4 100644 --- a/src/puter-shell/coreutils/coreutil_lib/help.js +++ b/src/puter-shell/coreutils/coreutil_lib/help.js @@ -41,6 +41,9 @@ export const printUsage = async (command, out, vars) => { const colorOptionArgument = text => { return `\x1B[91m${text}\x1B[0m`; }; + const wrap = text => { + return wrapText(text, vars.size.cols).join('\n') + '\n'; + } await heading('Usage'); if (!usage) { @@ -62,10 +65,7 @@ export const printUsage = async (command, out, vars) => { } if (description) { - const wrappedLines = wrapText(description, vars.size.cols); - for (const line of wrappedLines) { - await out.write(`${line}\n`); - } + await out.write(wrap(description)); await out.write(`\n`); } @@ -127,8 +127,7 @@ export const printUsage = async (command, out, vars) => { if (helpSections) { for (const [title, contents] of Object.entries(helpSections)) { await heading(title); - // FIXME: Wrap the text nicely. - await out.write(contents); + await out.write(wrap(contents)); await out.write('\n\n'); } }