CLI Framework¶
Requirements¶
Requirement: Command Base Class¶
The system SHALL provide an abstract Command base class for CLI command
implementations with type-safe argument parsing integration.
Scenario: Command implementation¶
WHEN a class inherits from
CommandTHEN it must implement an
execute()methodAND the command receives
Globalsfor access to framework state
Scenario: Command argument parsing¶
WHEN a command class defines typed fields
THEN
tyroautomatically generates argument parsing from type annotationsAND help text is generated from field docstrings
Scenario: Command execution¶
WHEN a command instance is called with
GlobalsTHEN the
execute()method is invoked with the provided stateAND the command can access configuration, directories, and inscription
Requirement: Application Base Class¶
The system SHALL provide an Application base class for CLI application
definition with automatic command routing.
Scenario: Application definition¶
WHEN a class inherits from
ApplicationTHEN it defines its command structure through typed fields
AND
tyrogenerates the CLI interface from the class definition
Scenario: Application preparation¶
WHEN
Application.prepare()is calledTHEN it extends the standard
prepare()with CLI-specific initializationAND display options and inscription are configured from CLI arguments
Scenario: Application execution¶
WHEN
Application()is called (the instance is callable)THEN argument parsing occurs via
tyroAND the application’s
execute()method is invoked withGlobals
Requirement: Command Routing via Type Guards¶
The system SHALL use isinstance() type guards for command routing within
CLI applications.
Scenario: Single command routing¶
WHEN an application has a single command type
THEN the application directly instantiates and executes the command
Scenario: Multiple command routing¶
WHEN an application has multiple command types
THEN the application uses
isinstance()checks to determine which command to executeAND each command type is a distinct class inheriting from
Command
Scenario: Subcommand composition¶
WHEN commands need subcommands
THEN each subcommand is a separate
CommandsubclassAND the parent command routes to subcommands via
isinstance()checks
Requirement: Display and Output Control¶
The system SHALL provide DisplayOptions for controlling output presentation
and routing.
Scenario: Presentation mode selection¶
WHEN display options specify a presentation mode (plain, rich, json, toml)
THEN output is formatted according to the selected mode
AND rich mode enables terminal-aware formatting when available
Scenario: Output stream routing¶
WHEN display options specify a target stream (stdout, stderr, file)
THEN output is directed to the specified stream
AND file targets are created with proper resource management
Scenario: Colorization control¶
WHEN display options specify colorization preferences
THEN ANSI color codes are applied or stripped accordingly
AND non-TTY streams automatically disable colorization