Skip to content

Commit

Permalink
improved cli to honor LANDO_ENTRYPOINT_NAME as yargs scriptname if set
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Mar 10, 2024
1 parent 744cfc7 commit 8364634
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## v3.21.0-beta.9 - [March 10, 2024](https://github.com/lando/cli/releases/tag/v3.21.0-beta.9)

### CLI

* Improved CLI to honor `LANDO_ENTRYPOINT_NAME` as the `yargs` `scriptName` if set

### Core

* Updated `@lando/core` to [`v3.21.0-beta.9`](https://github.com/lando/core/releases/tag/v3.21.0-beta.9)

## v3.21.0-beta.8 - [March 5, 2024](https://github.com/lando/cli/releases/tag/v3.21.0-beta.8)

### CLI
Expand Down
16 changes: 10 additions & 6 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,21 @@ module.exports = class Cli {
* Init
*/
init(yargs, tasks, config, userConfig) {
// @TODO: what if we are running from symlink?
// if we have LANDO_ENTRYPOINT_NAME
const $0 = process?.env?.LANDO_ENTRYPOINT_NAME ?? '$0';

// basic usage
const usage = ['Usage: $0 <command> [args] [options]'];
const usage = [`Usage: ${$0} <command> [args] [options]`];
// add experimental mode info
if (userConfig.experimental) usage.push(`${this.makeArt('print', {text: '(experimental mode)', color: 'magenta'})}`);

// Yargs!
yargs.usage(usage.join(' '))
.demandCommand(1, 'You need at least one command before moving on')
.example('$0 start', 'Run lando start')
.example('$0 rebuild --help', 'Get help about using the lando rebuild command')
.example('$0 destroy -y --debug', 'Run lando destroy non-interactively and with maximum verbosity')
.example('$0 --clear', 'Clear the lando tasks cache')
.example(`${$0} start`, 'Run lando start')
.example(`${$0} rebuild --help`, 'Get help about using the lando rebuild command')
.example(`${$0} destroy -y --debug`, 'Run lando destroy non-interactively and with maximum verbosity')
.example(`${$0} --clear`, 'Clear the lando tasks cache')
.middleware([(argv => {
argv._app = config;
})])
Expand All @@ -338,6 +339,9 @@ module.exports = class Cli {
.option('verbose', globalOptions.verbose)
.version(false);

// manually set scriptname if needed
if ($0 !== '$0') yargs.scriptName($0);

// Loop through the tasks and add them to the CLI
_.forEach(_.sortBy(tasks, 'command'), task => {
if (_.has(task, 'handler')) yargs.command(task);
Expand Down

0 comments on commit 8364634

Please sign in to comment.