import { CommandDescription } from '../command/command-models'; import { HelpUtilities } from './help-utilities'; /** * Inject token for the command help implementation * * @publicAPi */ export declare const COMMAND_HELP: unique symbol; /** * Interface that describes the implementation of the HelpModule that displays help messages for the usage * of a command. Accepts both synchronous and asynchronous implementations for interactive help implementations. * This is triggered when a command's execution path has been resolved and a help error has been caught. By default, * these errors would be `ParameterParsingError`, `OptionParsingError` or `TypeCastingError` as these can only be * thrown once a command has been resolved and its' options/parameters are parsed. The default implementation * is the `DefaultCommandHelp` service * * ### EXAMPLE * * #### When the command is not a star command * For simple commads, details of the applicable options and parameters are displayed, including whether these are required, * the descriptons and whether the options require values or can be utilized as boolean flags * ```sh * Error: * {ErrorMessage} * * Usage: * ? [options] [] * * Options: * --{name}, -{alias}? ? *required? {description | 'No description available'} * ... * * Parameters: * [?] {description | 'No description available'} * ... * ``` * #### When the command is a star command * When the command is a star command is displays a help message that is the same as the help message for a module, showing usage as both * an executable command as well as the underlying commands which can be executed from the 'module'. * ```sh * Error: * {ErrorMessage} * * Usage: * (1) ? []? [options] * (1) ? [options] [] * * Options: * --{name}, -{alias}? ? *required? {description | 'No description available'} * ... * * Parameters: * [?] {description | 'No description available'} * * Commands: * {command-name}, {command-alias}? {description | 'No description available'} * ... * * ``` * @publicAPi */ export interface CommandHelp { /** * Method that is called when the command help is triggered. * @param command Description of the command * @param error Error that was thrown to trigger the help implementation */ showHelp(command: CommandDescription, error?: ErrorType): void | Promise; } /** * The default implementation of the `CommandHelp` service which displays the applicable error message and the command's * usage, including all applicable options and parameters * * @publicAPi */ export declare class DefaultCommandHelp implements CommandHelp { private utils; /** * Creates a new instance * @param utils Utilitiy functions for printing help messages */ constructor(utils: HelpUtilities); /** * Method that is called when the command help is triggered, printing a description of how to use a command * @param command Description of the command * @param error Error that was thrown to trigger the help implementation */ showHelp(commandDescription: CommandDescription, error?: ErrorType): void; /** * Prints the usage of a star command * @param commandDescription Description of the command */ private normalCommand; /** * Prints the usage of a normal command * @param commandDescription Description of the command */ private starCommand; }