import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander'; import type { CommandActionModule } from '../types/CommandAction.js'; import type { SharedOptions } from '../types/SharedOptions.js'; import { type CommandExecutorParams } from './CommandExecutor.js'; /** * Parameters for creating a command. * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`. */ export interface CloudpackCommandParams extends Partial, 'discoverAppPaths' | 'enableReporterReset' | 'applyOptionsToConfig'>> { /** Command name */ name: string; /** Command description */ description: string; /** * Options specific to this command. The record ensures that all options are available in the CLI. * Allow multiple options for the same key since commander supports it with negatable options. */ options?: Record; /** Arguments specific to this command. Key order determines the arg order. */ args?: Record; /** * Function returning an async import of the command's `src/commands//execute.ts` module. * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse * every command's dependencies (many of which may be unrelated to the command being run). * * This can be undefined for a command that only has sub-commands. */ getExecutor?: () => Promise>; /** Usage message override */ usage?: string; /** Alternative name for the command */ alias?: string; /** Extra text to be displayed with the built-in help. */ addHelpText?: { /** * `'before'` or `'after'` to affect just this command. * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands. */ position: AddHelpTextPosition; text: string; }; /** Output options override (mainly for testing) */ outputOptions?: OutputConfiguration; /** * The shared options are relevant for most commands, but this allows omitting them from help * where they're not relevant. `true` hides all shared options, or an array hides specific ones. */ hideSharedOptions?: Array | true; } /** * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with * Cloudpack-specific functionality and simpler APIs. * * Similar to the pattern from `commander`, this class represents both the program and its sub-commands. * - The top-level "program" command should be created with `new CloudpackCommand()`. * - Sub-commands should be created with the `.addSubCommand` method on the parent. */ export declare class CloudpackCommand { private _command; private _executorOptions; /** * This should only be used directly (outside this class) to create the top-level `program` command. * To add sub-commands, use `.addSubCommand` instead. */ constructor(params: CloudpackCommandParams & Pick, 'programOptions'> & { /** This must be undefined for the top-level program command */ parent?: Command; }); /** Create a child command. */ addSubCommand(params: CloudpackCommandParams): CloudpackCommand; /** Run the program (only works on the top-level program command). */ run(): Promise; /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */ private _addArguments; /** Add options. The generic enforces that option objects are included for all keys of a type. */ private _addOptions; private _addAction; } //# sourceMappingURL=CloudpackCommand.d.ts.map