FUNC - Tiny typed CLI framework

Core Concepts

A func project registers decorated classes in a Container. At runtime, func parses the user input, chooses one matching handler, and injects provider objects into the handler constructor.

Handler Types

  • @Command handles named commands such as my-cli build.
  • @Option handles top-level options such as my-cli --version.
  • @SubOptions declares options that belong to a specific command, such as my-cli build --watch.
  • @CommandMajor handles the empty invocation, my-cli.
  • @CommandMissing handles unmatched input so you can print help, suggestions, or custom guidance.

Resolution Order

If the first user argument matches a command name or command alias, that command is executed and only its SubOptions are parsed. Registered global options do not run during command execution.

If no command is matched, func looks for one triggered global Option. Only one global option can be invoked at a time. If there is unmatched input, CommandMissing runs. If there is no input, CommandMajor runs.

Names and Option Types

Command and option names cannot be empty, start with -, or contain whitespace. Option aliases must be a single character, so alias: 'v' maps to -v.

Options default to Boolean. Use String or Number for scalar values, and [String] for repeated string values. The Array constructor is rejected so repeated values stay explicit.

Boundaries

func is intentionally small. It provides command registration, option parsing, constructor injection, and project tooling. It does not try to be a prompt toolkit, terminal UI framework, or general task runner.