Module

CLI

Decaf-ts' CLI module

View Source index.ts, line 3

Example
run module command     - $ npx decaf <module name> <module command> ...<module command options>
get module help        - $ npx decaf help <module name>;
list imported modules  - $ npx decaf list;
get cli help           - $ npx decaf help;

Members

# static constant CLI_FILE_NAME

The standard filename for CLI module files where each library must export a single CliModule function

The filename that identifies Decaf CLI modules

View Source constants.ts, line 2

# static constant VERSION

A constant that holds the version string of the package, which is replaced during build

Stores the current package version

View Source index.ts, line 17

Methods

# static demo() → {Command}

A minimal implementation showing how to extend the Decaf CLI with custom commands. This module demonstrates the pattern for creating CLI modules that can be discovered and loaded by the Decaf CLI.

Demo CLI module for Decaf libraries

sequenceDiagram participant User participant CLI participant DemoModule participant Command User->>CLI: npx decaf demo command "arg" CLI->>DemoModule: Load module DemoModule->>Command: Create command Command->>Command: Configure action Command-->>DemoModule: Return command DemoModule-->>CLI: Return command CLI->>Command: Execute with args Command->>Console: Log output

View Source demo/cli-module.ts, line 3

The Command object to be added to the main Decaf CLI

Command
Example
// Run the demo command with an argument
npx decaf demo command "something something"

// Output:
// executed demo command with type variable: something something

Type Definitions

# CliModule() → {Command|Promise.<Command>}

Defines the signature for CLI module functions that each Decaf module must export under the CLI_FILE_NAME file The function should return a Command object or a Promise that resolves to a Command object

Function type for Decaf CLI modules

View Source types.ts, line 6

A Command object or Promise that resolves to a Command object

Command | Promise.<Command>