Skip to content

Port ted to Terminal.Gui.Cli hosting #248

@tig

Description

@tig

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions