Skip to content

Latest commit

 

History

History
181 lines (130 loc) · 7.68 KB

API.md

File metadata and controls

181 lines (130 loc) · 7.68 KB

REPLClient

Kind: global class

new REPLClient(options)

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

replClient.run([commands], [options])

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

replClient.successLog(successMsg, [prefix], [noExit])

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

replClient.errorLog(errorMsg, [prefix], [noExit], [force])

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

replClient.exit([code], [override])

Exit process

Kind: instance method of REPLClient

Param Type Default Description
[code] Number 0 Exit status
[override] Boolean false Boolean to override interactive

replClient.pagination(output, pageInfo, [increments], [fn], [args]) ⇒ function | null

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

replClient.camelCaseToKebab(str) ⇒ String

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

replClient.kebabCaseToCamel(str) ⇒ String

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

replClient.promptInput(message, [secret]) ⇒ string

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

replClient.promptConfirm(message, options) ⇒ Boolean

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

replClient.promptList(message, [choices], [options]) ⇒ string

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