CliApp class
The standardized entry point for a Zuraffa CLI app (FR-001).
Construct one at app startup, register commands into its registry, then
call run from main(). The exit code returned by run is the value
main() should pass to dart:io's exit() (or, in tests, just return).
Apps that want to coexist with the existing CliRunner (e.g. for
migration) can do so — CliApp does not subclass CliRunner and does
not interfere with it.
Constructors
- CliApp({required String name, required String version, CliContract? contract, CommandRegistry? registry, StringSink? stdout, StringSink? stderr})
- Construct a CliApp with the standard contract and an empty registry.
- CliApp.withStandardContract({required String name, required String version, CommandRegistry? registry, StringSink? stdout, StringSink? stderr})
- Construct with the standard contract and a pre-built registry.
Properties
- contract → CliContract
-
The contract this app honors.
final
- defaultOwnerApp → String
-
The owner-app name used when registering commands via register.
Defaults to name; override by passing
ownerApp:to register.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The app name (shown in
--versionand the help header).final - registry → CommandRegistry
-
The registry of registered commands.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stderr → StringSink?
-
The stderr sink to write to. Defaults to the process
Stderrwhen null.final - stdout → StringSink?
-
The stdout sink to write to. Defaults to the process Stdout when null.
Tests may inject a StringBuffer to capture output.
final
- version → String
-
The app version (shown in
--version).final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register(
StandardCommand command, {String? ownerApp, String? version}) → void -
Register a command under
(defaultOwnerApp, command.name). -
run(
List< String> args) → Future<int> - Run the CLI with the given args vector. Returns the exit code.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited