Skip to content

Commit

Permalink
ensure usage keeps command title and description when overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Jul 15, 2024
1 parent c4ed80c commit fb73f80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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} <command> [args] [options]`];
const usage = [`${this.chalk.green('Usage:')}${EOL} ${$0} <command> [args] [options]`];
// add experimental mode info
if (userConfig.experimental) usage.push(`${this.makeArt('print', {text: '(experimental mode)', color: 'magenta'})}`);

Expand Down Expand Up @@ -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}`));
}
}};
}

Expand Down

0 comments on commit fb73f80

Please sign in to comment.