tasks

Contains some helpers to add and parse Lando tasks.

Lando tasks are a high level abstraction that should contain the neded information for both a GUI or CLI to present relevant UX to the user.

Since: 3.0.0
Example

// Gets all the tasks that have been loaded
var task = lando.tasks.tasks;

// Gets all the global options that have been specified.
var largv = lando.tasks.largv;

// Load in two tasks during bootstrap
lando.events.on('post-bootstrap', 1, function(lando) {

  // Load a task stored in a task module
  lando.tasks.add('config', require('./tasks/config')(lando));

  // Load a task stored in an object called task
  lando.tasks.add('config', task);

});

// Add a task so it shows up as a command in the CLI
yargs.command(lando.tasks.parseToYargs(task));

tasks.tasks

A singleton array that contains all the tasks that have been added.

Kind: static property of tasks
Since: 3.0.0
Example

// Gets all the tasks that have been loaded
var task = lando.tasks.tasks;

tasks.largv

A singleton object that contains the Lando global options.

This means all the options passed in after the -- flag.

Kind: static property of tasks
Since: 3.0.0
Example

// Gets all the global options that have been specified.
var largv = lando.tasks.largv;

tasks.parseGlobals()

Helper function to parse global opts

Kind: static method of tasks
See: https://github.com/lando/lando/issues/351
Since: 3.0.0
Example

// Gets all the tasks that have been loaded
var largv = lando.tasks.parseGlobals();

tasks.argv()

Returns the lando options

This means all the options passed in before the -- flag.

Kind: static method of tasks
Since: 3.0.0
Example

// Gets all the global options that have been specified.
var argv = lando.tasks.argv;

tasks.parseToYargs(task) ⇒ Object

Parses a lando task object into something that can be used by the yargs CLI.

A lando task object is an abstraction on top of yargs that also contains some metadata about how to interactively ask questions on both the CLI and GUI. While this method is useful, any task added to Lando via lando.tasks.add will automatically be parsed with this method.

The interactivity metadata is light wrapper around inquirer

Kind: static method of tasks
Returns: Object - A yargs command object
See

Since: 3.0.0

Param Type Description
task Object A Lando task object (@see add for definition)

Example

// Add that task to the CLI
yargs.command(lando.tasks.parseToYargs(task));

tasks.add(name, task)

Adds a Lando task to the global lando.tasks.task object.

A lando task object is an abstraction on top of yargs and inquirer with a little extra special sauce.

Kind: static method of tasks
See

Since: 3.0.0

Param Type Description
name String The name of the task.
task Object A Lando task object
task.command String A yargs formatted command
task.description String A short description of the command
task.options Object A yargs builder object. Each builder also has an 'interactive' key which is an inquirier question object
task.run function The function to run when the task is invoked.
task.run.options Object The options selected by the user, available to the run function.

Example

// Define a task
var task = {
  command: 'destroy [appname]',
  describe: 'Destroy app in current directory or [appname]',
  options: {
    yes: {
      describe: 'Auto answer yes to prompts',
      alias: ['y'],
      default: false,
      boolean: true,
      interactive: {
        type: 'confirm',
        message: 'Are you sure you want to DESTROY?'
      }
    }
  },
  run: function(options) {
    console.log(options);
  }
};

// Add the task to Lando
lando.tasks.add('destroy', task);

"event:task-CMD-answers"

Event that allows altering of argv or inquirer before interactive prompts are run

Kind: event emitted by tasks
Since: 3.0.0
Properties

Name Type Description
answers Object argv and inquirer questions

"event:task-CMD-run"

Event that allows final altering of answers

Kind: event emitted by tasks
Since: 3.0.0
Properties

Name Type Description
answers Object object

results matching ""

    No results matching ""