Motivation
examples/ted currently hand-rolls its hosting in Program.cs: ad-hoc args scanning for --read-only/-r and a positional file path, plus direct Application.Create()/Init()/Run() lifecycle management.
The Terminal.Gui.Cli package (https://github.com/gui-cs/cli, on NuGet as Terminal.Gui.Cli) is the hosting layer for exactly this: CLI parsing, command dispatch, Terminal.Gui lifecycle ownership, plain/JSON output envelopes, and AI-agent discoverability (--help rendered from markdown, --opencli, --cat). ted is the flagship Editor example and should demonstrate the recommended hosting pattern instead of a bespoke one.
Scope
- Add a
Terminal.Gui.Cli package reference to examples/ted.
- Introduce a
TedCommand (IViewerCommand, fullscreen) that owns the file-open logic (missing-file, synchronous small-file, progressive large-file paths) and the --read-only option, receiving the host-initialized IApplication.
- Set it as the host''s
DefaultCommand so existing invocations keep working unchanged: ted, ted file.txt, ted -r file.txt.
--cat <file> renders the file to stdout without launching the TUI (viewer contract).
- For free from the host:
--help (ANSI markdown), --version, --opencli, --json envelopes, --timeout, usage errors with proper exit codes.
- Keep
Hosting.ConfigureLogging/EnableTracing and ConfigurationManager.Enable in Program.cs (process-wide concerns stay outside the command).
- Tests for the command metadata,
--cat behavior, and --read-only/default-command dispatch.
Non-goals
- No changes to
TedApp itself or the Editor view.
- No new ted features beyond what the host provides.
Motivation
examples/tedcurrently hand-rolls its hosting inProgram.cs: ad-hocargsscanning for--read-only/-rand a positional file path, plus directApplication.Create()/Init()/Run()lifecycle management.The
Terminal.Gui.Clipackage (https://github.com/gui-cs/cli, on NuGet asTerminal.Gui.Cli) is the hosting layer for exactly this: CLI parsing, command dispatch, Terminal.Gui lifecycle ownership, plain/JSON output envelopes, and AI-agent discoverability (--helprendered from markdown,--opencli,--cat). ted is the flagship Editor example and should demonstrate the recommended hosting pattern instead of a bespoke one.Scope
Terminal.Gui.Clipackage reference toexamples/ted.TedCommand(IViewerCommand, fullscreen) that owns the file-open logic (missing-file, synchronous small-file, progressive large-file paths) and the--read-onlyoption, receiving the host-initializedIApplication.DefaultCommandso existing invocations keep working unchanged:ted,ted file.txt,ted -r file.txt.--cat <file>renders the file to stdout without launching the TUI (viewer contract).--help(ANSI markdown),--version,--opencli,--jsonenvelopes,--timeout, usage errors with proper exit codes.Hosting.ConfigureLogging/EnableTracingandConfigurationManager.EnableinProgram.cs(process-wide concerns stay outside the command).--catbehavior, and--read-only/default-command dispatch.Non-goals
TedAppitself or theEditorview.