Kind: global class
- REPLClient
- new REPLClient(options)
- .run([commands], [options])
- .successLog(successMsg, [prefix], [noExit])
- .errorLog(errorMsg, [prefix], [noExit], [force])
- .exit([code], [override])
- .pagination(output, pageInfo, [increments], [fn], [args]) ⇒
function
|null
- .camelCaseToKebab(str) ⇒
String
- .kebabCaseToCamel(str) ⇒
String
- .promptInput(message, [secret]) ⇒
string
- .promptConfirm(message, options) ⇒
Boolean
- .promptList(message, [choices], [options]) ⇒
string
Instantiate the CLI
Param | Type | Default | Description |
---|---|---|---|
options | Object |
options | |
[options.enableInteractive] | Boolean |
true |
Allow interactive mode |
[options.exceptions] | Array.<String> |
[] |
The ability to explicitely not execute code before the actual command. E.g. an API call. |
[options.helpHeader] | String |
Header to show in help | |
[options.helpFooter] | String |
Footer to show in help | |
[options.binCommand] | String |
If error it will show how to access the help command | |
[options.logStackErrorMessages] | Boolean |
For debug purposes | |
[options.tabSize] | Number |
15 |
Tab size between command and help |
[options.argv] | String |
Manually pass arguments to cli (used for testing) | |
[options.actions] | Object.<String, function()> |
{} |
Actions to mount to the CLI |
This is the initial entry to initialize the cli REPLClient.run({ commands })
Kind: instance method of REPLClient
Param | Type | Default | Description |
---|---|---|---|
[commands] | Object |
{} |
Command object with function to execute |
[options] | Object |
{} |
Command object with function to execute |
When non-interactively it will exit, unless noExit is provided.
Kind: instance method of REPLClient
Param | Type | Default | Description |
---|---|---|---|
successMsg | String |
Succes string to log | |
[prefix] | String |
'' |
Add a prefix to the message, it will print the message under a newline |
[noExit] | Boolean |
false |
Force to not exit |
When non-interactively it will exit, unless noExit is provided.
Kind: instance method of REPLClient
Param | Type | Default | Description |
---|---|---|---|
errorMsg | String |
Succes string to log | |
[prefix] | String |
'' |
Add a prefix to the message, it will print the message under a newline |
[noExit] | Boolean |
false |
Force to not exit |
[force] | Boolean |
false |
Force to exit |
Exit process
Kind: instance method of REPLClient
Param | Type | Default | Description |
---|---|---|---|
[code] | Number |
0 |
Exit status |
[override] | Boolean |
false |
Boolean to override interactive |
Clears the console to present the result(s)
Kind: instance method of REPLClient
Param | Type | Default | Description |
---|---|---|---|
output | any |
What info will be outputted through the successLog method |
|
pageInfo | Object |
Info about the page | |
[pageInfo.offset] | Number |
1 |
Offset of the query |
[pageInfo.limit] | Number |
1 |
Limit of the query |
[pageInfo.pageNumber] | Number |
1 |
Number of the current page |
[pageInfo.order] | 'asc' | 'desc' |
'asc' |
Order to run the query |
[increments] | Number |
1 |
Increments on offset en limit (is always lowercase) |
[fn] | function |
()=>{} |
Function to execute while keeping page interactive |
[args] | Array.<string> |
[] |
Arguments to pass on through the given fn function |
Converts camelCase to kebas-case
Kind: instance method of REPLClient
Returns: String
- kebab-case value
Throws:
TypeError
No string given or not a string
Param | Type | Description |
---|---|---|
str | String |
String to be converted to kebab-case |
Converts kebab-case to camelCase
Kind: instance method of REPLClient
Returns: String
- camelCase value
Throws:
TypeError
No string given or not a string
Param | Type | Description |
---|---|---|
str | String |
String to be converted to camelCase |
Prompt wrapper function
Kind: instance method of REPLClient
Returns: string
- Value given to prompt
Param | Type | Description |
---|---|---|
message | String |
Prompt message |
[secret] | Boolean |
When true input is hidden |
Confirmation Prompt
Kind: instance method of REPLClient
Returns: Boolean
- Value given to prompt
Param | Type | Description |
---|---|---|
message | String |
Message of confirmation |
options | Object |
|
options.default | any |
Default of confirmation |
Confirmation Prompt
Kind: instance method of REPLClient
Returns: string
- Value given to prompt
Param | Type | Default | Description |
---|---|---|---|
message | String |
Message of confirmation | |
[choices] | Array |
[] |
Choices to list in the prompt |
[options] | Object |
||
[options.default] | any |
Default of confirmation |