yargs-file-commands
Version:
A yargs helper function that lets you define your commands structure via directory and file naming conventions.
34 lines (33 loc) • 1.41 kB
TypeScript
import { type ScanDirectoryOptions } from './scanDirectory.js';
/**
* Configuration options for file-based command generation
* @interface FileCommandsOptions
*/
export type FileCommandsOptions = ScanDirectoryOptions & {
/** Array of directory paths to scan for command files */
commandDirs: string[];
};
/**
* Default configuration options for file-based commands
* @constant
* @type {Partial<FileCommandsOptions>}
*/
export declare const DefaultFileCommandsOptions: Required<FileCommandsOptions>;
/**
* Generates a command tree structure from files in specified directories
* @async
* @param {FileCommandsOptions} options - Configuration options for command generation
* @returns {Promise<Command[]>} Array of root-level commands with their nested subcommands
*
* @description
* This function scans the specified directories for command files and builds a hierarchical
* command structure based on the file system layout. It processes files in parallel for better
* performance and supports nested commands through directory structure.
*
* The function will:
* 1. Scan all specified command directories
* 2. Process found files to extract command information
* 3. Build a tree structure based on file paths
* 4. Convert the tree into a command hierarchy
*/
export declare const fileCommands: (options: FileCommandsOptions) => Promise<import("yargs").CommandModule<{}, {}>[]>;