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
'use strict'
const ActionHero = require('actionhero')
module.exports = class MyCLICommand extends ActionHero.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}) {
const api = ActionHero.api
return api.cache.dumpWrite(params.file)
}
}
Methods
(async, static) run(data)
- Source:
The main "do something" method for this CLI command. It can be async. 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. |