CLI

Table of Contents
Examples
Basic Usage
JavaScript Reference
getArgs
runChildProcess
runChildNodeProcess

Description

The CLI utility provides command-line interface functionalities for Kempo.

Basic Usage

import { getArgs, runChildProcess, runChildNodeProcess } from '../src/utils/cli.js';

const args = getArgs();
console.log(args);

runChildProcess('echo Hello World').then(console.log).catch(console.error);

runChildNodeProcess('path/to/script.js', { debug: true }).then(console.log).catch(console.error);

JavaScript Reference

getArgs

getArgs(shortMap config)

Parameters

shortMap: object

Mapping of short argument names to long argument names.

Returns

An object containing the parsed arguments.

runChildProcess

runChildProcess(command string)

Parameters

command: string

The command to run in the child process.

Returns

A promise that resolves when the child process exits successfully, and rejects if it exits with an error.

runChildNodeProcess

runChildNodeProcess(scriptPath string, argsObj object)

Parameters

scriptPath: string

The path to the Node.js script to run.

argsObj: object

An object containing the arguments to pass to the script.

Returns

A promise that resolves when the child process exits successfully, and rejects if it exits with an error.