vtex
Version:
The platform for e-commerce apps
47 lines (46 loc) • 2.21 kB
TypeScript
export interface CommandI {
name: string;
description: string;
}
export declare function getHelpSubject(args: string[]): string | undefined;
/**
* Detects whether the current invocation is a help request, covering every
* help form: `vtex help`, `vtex help <command>`, `vtex --help` / `-h` (oclif
* passes the bare flag as the command id itself) and `vtex <command> --help` /
* `-h` (`-h` is globally reserved for help in CustomCommand).
*
* Note on the `--` separator: everything after `--` is forwarded verbatim to
* the underlying command as positional values (consistent with
* `getHelpSubject` above), so `vtex cmd -- --help` must NOT be treated as a
* help invocation. Only flags appearing before `--` are considered.
*/
export declare function isHelpInvocation(commandId: string | undefined, argv: string[]): boolean;
/**
* Flattens the oclif config's commands and topics into the flat `CommandI`
* list used by the help output, dropping namespaced entries (those containing
* a `:`) so only top-level commands/topics are shown.
*/
export declare function collectCommands(commands: ReadonlyArray<{
id: string;
description: string;
}>, topics: ReadonlyArray<{
name: string;
description: string;
}>): CommandI[];
/**
* Buckets the CLI's commands/topics into display groups for the help output.
*
* The group metadata (`commandsGroup` maps command name -> group id, and
* `commandsId` maps group id -> group label) comes from a feature-flag store
* that is populated by a non-blocking child process. On a fresh install those
* values may still be undefined, so we fall back to rendering every command
* under a single default ("Other") group so that help always works.
*
* Commands with no known group id (or a falsy one) are placed in the last
* group. Duplicate command names are rendered only once.
*/
export declare function buildCommandGroups(commandsGroup: Record<string, number> | undefined, commandsId: Record<number, string> | undefined, allCommands: CommandI[]): {
commandsId: Record<number, string>;
groups: CommandI[][];
};
export declare function renderCommands(commandsId: Record<number, string>, groups: CommandI[][], ctx: any): string;