yargs-file-commands
Version:
A yargs helper function that lets you define your commands structure via directory and file naming conventions.
27 lines (26 loc) • 1.31 kB
TypeScript
import type { CommandBuilder, CommandModule } from 'yargs';
/**
* Extracts positional argument names from a command string.
* Handles patterns like: "create <name>", "create <name> [optional]", etc.
*
* @param commandString - The command string (e.g., "create <serviceAccount> <token>")
* @returns Array of positional argument names found in the command string
*/
export declare function extractPositionalsFromCommandString(commandString: string | readonly string[] | undefined): string[];
/**
* Extracts positional argument names from a builder function by executing it
* with a mock yargs instance and tracking what positionals are registered.
*
* @param builder - The command builder function
* @returns Array of positional argument names registered in the builder
*/
export declare function extractPositionalsFromBuilder(builder: CommandBuilder | undefined): Promise<string[]>;
/**
* Validates that positional arguments registered in the builder match
* those declared in the command string.
*
* @param commandModule - The command module to validate
* @param filePath - Path to the command file (for error messages)
* @throws Error if validation fails and positionals don't match
*/
export declare function validatePositionals(commandModule: CommandModule, filePath: string): Promise<void>;