CLI

ActionHero. CLI

new CLI()

Source:
Tutorials:
Properties:
Name Type Description
name string

The name of the CLI command.

description string

The description of the CLI command (default this.name).

example string

An example of how to run this CLI command.

inputs Object

The inputs of the CLI command (default: {}).

Create a new ActionHero CLI Command. The required properties of an CLI command. These can be defined statically (this.name) or as methods which return a value.

Example
const {CLI, api} = require('actionhero')

module.exports = class MyCLICommand extends CLI {
  constructor () {
    super()
    this.name = 'backup redis'
    this.description = 'I save the contents of redis to a file'
    this.example = 'actionhero backup redis --file=/path/to/file'
    this.inputs = {
      file: {required: true}
    }
  }

  async run ({params}) {
    await api.cache.dumpWrite(params.file)
    return true
  }
}

Methods

(async, static) run(data) → {Promise.<Boolean>}

Source:

The main "do something" method for this CLI command. It is an async method. If error is thrown in this method, it will be logged to STDERR, and the process will terminate with a non-0 exit code.

Parameters:
Name Type Description
data Object

The data about this instance of the CLI run, specifically params.

Returns:

The return value of run is toShutdown (boolean). If you return true, the CLI process will exit if when the method returns, false will keep running.

Type
Promise.<Boolean>