- cliDescription(...args)
Create a description for the CLI. That description will be displayed when calling the function with
-h
or--help
. This is usually a one liner summary of what the function does.- cliGroup(cliGroup)
Create a group or several groups for the function in CLI form. To create a nested group inside a group, you can chain the group names with a
.
.- cliRename(newFunctionName)
Give this function a different name in CLI mode. This is usually combined with
@cliGroup
to allow function hierarchy, like nesting set and get functions inside a group.- cliOptionalParams(optionalArray)
Optional params for this function. Usually when a default value is set to that param in typescript or passed from the @cliBeforeEach function
- cliHiddenParams(hiddenArray)
HIDDEN params for this function. Usually when a beforeEach function passes that argument instead
- cliBeforeEach()
Runs before all function called. The function should return an object with keys as input names and value as the value passed. You can also return a promise that resolves to an object. For example, you might want to fetch a token from the system's keychain in order to do an http request, or ask the user to input a username and password in an
inquirer.js
manner- cliAfterEach()
runs after all functions called.
- cliIgnore()
Ignore this function when translating the class into a CLI.
Create a description for the CLI.
That description will be displayed when
calling the function with -h
or --help
.
This is usually a one liner summary of
what the function does.
Kind: global function
Param | Description |
---|---|
...args | the description of the function |
Example
.@cliDescription(`get the user's info`)
static getUserInfo(userId) { ... }
Create a group or several groups
for the function in CLI form.
To create a nested group inside a group,
you can chain the group names with a .
.
Kind: global function
Param | Type | Description |
---|---|---|
cliGroup | string |
The group path string. every inner group is separated by a dot (.) |
Example
// will create a cli command:
// $ cli user info get <user_id>
.@cliRename('get')
.@cliGroup('user.info')
static getUserInfo(userId) { ... }
Give this function a different name
in CLI mode.
This is usually combined with @cliGroup
to allow function hierarchy, like
nesting set and get functions inside a group.
Kind: global function
Param | Type | Description |
---|---|---|
newFunctionName | string |
the new function name |
Example
// will create a cli command:
// $ cli get <user_id>
.@cliRename('get')
static getUserInfo(userId) { ... }
Optional params for this function. Usually when a default value is set to that param in typescript or passed from the @cliBeforeEach function
Kind: global function
Param | Type | Description |
---|---|---|
optionalArray | Array.<string> |
array of optional params |
Example
// will create a cli command:
// $ cli renameUser <new_name>
.@cliOptionalParams(['newName'])
static renameUser(newName: string = randomName()) { ... }
cliHiddenParams(hiddenArray)
HIDDEN params for this function. Usually when a beforeEach function passes that argument instead
Kind: global function
Param | Type | Description |
---|---|---|
hiddenArray | Array.<string> |
array of hidden params |
Example
// won't ask the user to set a token.
.@cliHiddenParams(['token'])
static getUserInfo(token: string, ) { ... }
Runs before all function called.
The function should return an object
with keys as input names and value as the
value passed. You can also return
a promise that resolves to an object.
For example, you might want to fetch a
token from the system's keychain in
order to do an http request, or ask
the user to input a username and password
in an inquirer.js
manner
Kind: global function
Example
// won't ask the user to set a token.
.@cliBeforeEach()
static fetchTokenFromKeychain() {
return keytar.getPassword(cfg.username)
.then((token) => ({ token: token }))
.catch(() => throw new Error('user not logged in'));
}
runs after all functions called.
Kind: global function
Example
.@cliAfterEach()
static logResult(functionName, returnValue, givenParams) {
console.log('function result: ', returnValue);
}
Ignore this function when translating the class into a CLI.
Kind: global function
Example
.@cliIgnore()
static dontTraslate(arg) { ... }