• Executes a command based on the parsed arguments.

    This function:

    1. Finds the requested command
    2. Handles subcommand routing if present
    3. Executes the command's action or shows help

    Parameters

    • args: ParsedArgs

      Parsed command-line arguments

    • commands: Command[]

      Available commands to execute

    Returns void

    const gitCommands: Command[] = [{
    name: 'commit',
    description: '📝 Create a commit',
    options: [{
    name: 'message',
    description: 'Commit message',
    defaultValue: 'Update'
    }],
    action: (args) => {
    console.log(`📝 Committing with message: ${args.message}`);
    }
    }];

    // Parse and execute
    const args = parseCliArgs(['commit', '--message', 'Fix bugs']);
    executeCommand(args, gitCommands);

    If a required positional argument is missing