Class: CLI

CLI(setup)

Class representing a Command Line Interface (CLI) application.

Constructor

new CLI(setup)

Creates an instance of CLI.

Parameters:
Name Type Description
setup Object

The setup configuration for the CLI.

Properties
Name Type Description
startView string

The initial view to be displayed upon CLI initialization.

startViewParams Object

The parameters to be passed to the initial view.

Source:

Extends

Members

StringBuilder :StringTemplateBuilder

The StringTemplateBuilder instance used for constructing string templates.

Type:
Overrides:
Source:

startView :string

The name of the initial view to be displayed upon CLI initialization.

Type:
  • string
Source:

startViewParams :Object

The parameters to be passed to the initial view.

Type:
  • Object
Source:

Methods

boolAnswer(a, strictopt) → {boolean}

Converts a user input to a boolean value, considering 'y' or 'n' as affirmative and negative answers, respectively.

Parameters:
Name Type Attributes Default Description
a string

The user input to be converted to a boolean value ('y' or 'n').

strict boolean <optional>
false

If set to true, strict mode requires 'y' or 'n' input only.

Overrides:
Source:
Throws:

When strict mode is enabled and the input is not 'y' or 'n'.

Type
Error.Log
Returns:

The boolean value based on the user input.

Type
boolean

getCurrentView() → {string}

Gets the name of the current view.

Source:
Returns:

The name of the current view.

Type
string

(async) goToStart() → {View}

Navigates back to the initial view of the CLI application.

Source:
Returns:

The loaded initial view instance.

Type
View

(async) init() → {CLI}

Initializes the CLI application by loading the initial view.

Source:
Returns:

The CLI instance.

Type
CLI

(async) loadView(viewPath, viewParams) → {View}

Loads a specific view into the CLI application.

Parameters:
Name Type Description
viewPath string

The path to the view module.

viewParams Object

The parameters to be passed to the view.

Source:
Throws:

If the specified view path is not found.

Type
Error.Log
Returns:

The loaded view instance.

Type
View

print(txt, addHeaderopt)

Prints a message to the console with optional header and project name.

Parameters:
Name Type Attributes Description
txt string

The text to be printed.

addHeader string <optional>

The optional header to be added to the message.

Overrides:
Source:

printError(err)

Prints an error message to the console, including error name, message, and stack trace.

Parameters:
Name Type Description
err Error

The error object to be printed.

Overrides:
Source:

printTable(data, optionsopt)

Prints tabular data to the console as a table.

Parameters:
Name Type Attributes Description
data Object

The data to be displayed in the table.

options Object <optional>

Additional options for printing the table, including headers.

Overrides:
Source:

printTemplate(stringContent)

Prints a string template content to the console.

Parameters:
Name Type Description
stringContent string

The string template content to be printed.

Overrides:
Source:

setCurrentView(viewName) → {string}

Sets the current view of the CLI application.

Parameters:
Name Type Description
viewName string

The name of the view to set as the current view.

Source:
Returns:

The name of the current view.

Type
string