Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added examples support to tasks #276

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### New Features

* Added `positional` and `usage` `yargs` parsing to incomings tasks
* Added `examples`, `positional`, and `usage` `yargs` parsing to incomings tasks

### Internals

Expand Down
22 changes: 17 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ module.exports = class Cli {
// 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`, 'Runs lando start')
.example(`${$0} rebuild --help`, 'Gets help about using the lando rebuild command')
.example(`${$0} destroy -y --debug`, 'Runs lando destroy non-interactively and with maximum verbosity')
.example(`${$0} --clear`, 'Clears the lando tasks cache')
.parserConfiguration({'populate--': true})
.recommendCommands()
.wrap(yargs.terminalWidth() * 0.70)
Expand Down Expand Up @@ -401,7 +401,16 @@ module.exports = class Cli {
* // Add a task to the yargs CLI
* yargs.command(lando.tasks.parseToYargs(task));
*/
parseToYargs({command, describe, options = {}, positionals = {}, run = {}, level = 'app', usage = undefined}, config = {}) {
parseToYargs({
command,
describe,
examples = [],
options = {},
positionals = {},
run = {},
level = 'app',
usage = undefined,
} = {}, config = {}) {
const handler = argv => {
// Immediately build some arg data set opts and interactive options
const data = {options: argv, inquiry: formatters.getInteractive(options, argv)};
Expand Down Expand Up @@ -485,6 +494,9 @@ module.exports = class Cli {
}
}

// examples are also good!
for (const example of examples) yargs.example(...example);

// and also allow usage
if (usage) yargs.usage(`${this.chalk.green('Usage:')}\n ${usage}`);
}};
Expand Down
Loading