Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:20000419 Fauxnix CLI Dispatch

From Leeroopedia
Knowledge Sources
Domains CLI, Dispatch
Last Updated 2026-10-26 00:00 GMT

Overview

A command-dispatch pattern that inspects the first argv token and routes to a subcommand handler, with the default verb joining the remaining tokens into a command string for immediate execution.

Description

CLI Dispatch is the routing layer of a multi-verb command-line tool. Rather than a single fixed behavior, the tool inspects the first argument (the "verb") and delegates to a specialized handler: translate, mcp, list, check, doctor, install, facade, or --version. When no recognized verb is present, the default behavior joins all argv tokens into a single command string and executes it. This dual nature — subcommand router plus default pass-through executor — lets a single binary serve as both an interactive command runner and a management tool. It solves the problem of overloading a thin CLI entry with many distinct operational modes while keeping the common case (run a command) zero-friction.

Usage

Use this pattern when a single CLI binary must support both a primary action (execute a command) and a set of management subcommands (install, diagnose, serve). It is the right choice when the primary action's input is naturally "the rest of the argv" and the subcommands are opt-in.

Theoretical Basis

The dispatch is a simple prefix-match on argv[0]:

if argv[0] in {translate, mcp, list, check, doctor, install, facade, --version}:
    delegate to subcommand(argv[1:])
else:
    command = join(argv, ' ')
    parse → translate → execute → print

No option parsing framework is needed because the verbs are mutually exclusive and the default path consumes the entire argv. Subcommands that take flags (install --claude) parse their own rest slice.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment