UNPKG

@nu-art/commando

Version:

Shell command execution framework with interactive sessions, CLI parameter resolution, and plugin system for building and executing shell scripts programmatically

56 lines (55 loc) 2.12 kB
import { BaseCommando } from '../core/BaseCommando.js'; import { CliBlock } from '../types.js'; /** * Programming constructs plugin for Commando. * * Provides control flow structures for building shell scripts: * - Conditionals (`if`/`else`) * - Loops (`for`, `while`) * - Functions * * These methods build shell script structures with proper indentation * and syntax, allowing programmatic construction of complex shell scripts. */ export declare class Commando_Programming extends BaseCommando { /** * Constructs an if-else conditional command structure. * @param {string} condition - The condition for the if statement. * @param {CliBlock} ifBlock - Block of commands to execute if the condition is true. * @param {CliBlock} [elseBlock] - Optional block of commands to execute if the condition is false. * @returns {this} - The Cli instance for method chaining. */ if(condition: string, ifBlock: CliBlock<this>, elseBlock?: CliBlock<this>): this; /** * Constructs a for loop command structure. * @param {string} varName - The variable name used in the loop. * @param {string | string[]} arrayNameOrValues - The array name or array of values to iterate over. * @param {CliBlock} loop - Block of commands to execute in each iteration of the loop. * @returns {this} - The Cli instance for method chaining. */ for(varName: string, arrayNameOrValues: string | string[], loop: CliBlock<this>): this; /** * Appends a 'continue' command for loop control. * * Skips to the next iteration of the innermost loop. * * @returns This instance for method chaining */ continue(): this; /** * Appends a 'break' command for loop control. * * Exits the innermost loop. * * @returns This instance for method chaining */ break(): this; /** * Appends a 'return' command for exiting a function or script. * * Exits the current function or script with optional exit code. * * @returns This instance for method chaining */ return(): this; }