From fb73f800b0b856f2cd8b207ab8073350f4862ca7 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Mon, 15 Jul 2024 11:56:00 -0400 Subject: [PATCH] ensure usage keeps command title and description when overridden --- lib/cli.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index c16cd978c..3a4f1599e 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -6,6 +6,8 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); +const EOL = os.EOL; + const formatters = require('./formatters'); const getSysDataPath = require('../utils/get-system-data-dir'); @@ -314,7 +316,7 @@ module.exports = class Cli { const $0 = process?.env?.LANDO_ENTRYPOINT_NAME ?? '$0'; // basic usage - const usage = [`${this.chalk.green('Usage:')}\n ${$0} [args] [options]`]; + const usage = [`${this.chalk.green('Usage:')}${EOL} ${$0} [args] [options]`]; // add experimental mode info if (userConfig.experimental) usage.push(`${this.makeArt('print', {text: '(experimental mode)', color: 'magenta'})}`); @@ -501,7 +503,13 @@ module.exports = class Cli { } // and also allow usage - if (usage) yargs.usage(`${this.chalk.green('Usage:')}\n ${usage}`); + if (usage) { + const prefix = [`$0 ${command}`]; + // add description if available + if (describe) prefix.push(describe); + // and put it 2getha + yargs.usage([...prefix, `${this.chalk.green('Usage:')}${EOL} ${usage}`].join(`${EOL}${EOL}`)); + } }}; }