@adonisjs/ace
Version:
A CLI framework for Node.js
77 lines (76 loc) • 2.38 kB
TypeScript
import type { AllowedInfoValues, CommandMetaData, UIPrimitives } from '../types.ts';
/**
* The command formatter exposes API to format command data for the
* commands list and the command help
*
* @example
* ```ts
* const formatter = new CommandFormatter(command, colors)
* const usage = formatter.formatUsage(['alias'], 'node ace')
* const description = formatter.formatDescription()
* ```
*/
export declare class CommandFormatter {
#private;
/**
* Create a new command formatter
*
* @param command - The command metadata to format
* @param colors - Color utilities for output formatting
*/
constructor(command: CommandMetaData, colors: UIPrimitives['colors']);
/**
* Returns the formatted command name to be displayed in the list of commands
*
* @param aliases - Array of command aliases
*
* @example
* ```ts
* formatter.formatListName(['make']) // ' generate:model (make) '
* ```
*/
formatListName(aliases: string[]): string;
/**
* Returns the formatted description of the command
*
* @example
* ```ts
* formatter.formatDescription() // 'Generate a new model'
* ```
*/
formatDescription(): string;
/**
* Returns multiline command help with proper text wrapping
*
* @param binaryName - The binary name for interpolation
* @param terminalWidth - Terminal width for text wrapping
*
* @example
* ```ts
* formatter.formatHelp('node ace') // Formatted help text
* ```
*/
formatHelp(binaryName?: AllowedInfoValues, terminalWidth?: number): string;
/**
* Returns the formatted description to be displayed in the list of commands
*
* @example
* ```ts
* formatter.formatListDescription() // Dimmed description text
* ```
*/
formatListDescription(): string;
/**
* Returns an array of strings, each line contains an individual usage example
*
* @param aliases - Array of command aliases
* @param binaryName - The binary name for usage examples
*
* @example
* ```ts
* formatter.formatUsage(['make'], 'node ace')
* // [' node ace generate:model [options] <name>', ' node ace make [options] <name>']
* ```
*/
formatUsage(aliases: string[], binaryName?: AllowedInfoValues): string[];
}