You can also add a ready function to your command to perform startup tasks to be run when your command is invoked, but before run is called. CLI supports ready returning a promise for asynchronous support.

For instance, you may want to ready to load data to be used during the execution of the command:

import{FS}from'grind-support'

exportclassMakeThingCommandextendsCommand{

ready(){

returnFS.readFile(this.app.paths.base('countries.json'))

.then(data=>{

this.countries=JSON.parse(data)

})

}

}

Now when run is called, it will already have this.countries populated.

fallback — Optional parameter to provide a default value for optional arguments. Passing a value here for a required argument will have no effect, since the your command won’t execute unless all required arguments are satisfied.

this.confirm('Are you sure you want to proceed?',false).then(answer=>/* … */)

The confirm function is a helpful wrapper around ask for asking binary questions. The first parameter is question, which is outputted to the user. The second parameter is defaultAnswer, the defaultAnswer answer is used when the user provides no response and just hits enter.

confirm will accept accept the following user answers as true (case-insensitive):