Skip to content

Adopt Terminal.Gui.Cli package, replacing internal CLI infrastructure#185

Merged
tig merged 3 commits into
developfrom
tig/adopt-terminal-gui-cli-package
May 27, 2026
Merged

Adopt Terminal.Gui.Cli package, replacing internal CLI infrastructure#185
tig merged 3 commits into
developfrom
tig/adopt-terminal-gui-cli-package

Conversation

@tig
Copy link
Copy Markdown
Member

@tig tig commented May 25, 2026

Summary

Replaces clet's internal CLI hosting infrastructure with the Terminal.Gui.Cli NuGet package (0.1.0-develop.2), as tracked in #180.

What changed

Deleted (now provided by the package):

  • src/Clet/Abstractions/IClet, IClet<T>, IViewerClet, ICletRegistry, CletKind, CletRunResult<T>, CletRunStatus, CletRunOptions, CletOptionDescriptor, BoxedCletResult
  • src/Clet/Registry/CletRegistry, BuiltInClets
  • src/Clet/Json/SchemaV1, CletJsonContext
  • src/Clet/Hosting/CommandLineRoot, AliasDispatcher, OutputFormatter, ExitCodes, CletTypeNames, TerminalEscapeSanitizer, MarkdownHelpRenderer
  • src/Clet/Clets/Viewer/HelpClet.cs — replaced by package's built-in help command
  • 7 unit test files testing the above infrastructure

Created:

  • src/Clet/Hosting/BuiltInCommands.cs — static registration helper for all 17 commands
  • src/Clet/Hosting/CletHelpProvider.cs — custom IHelpProvider implementation
  • src/Clet/Hosting/CletOptionsExtensions.cs — extension methods for accessing clet-specific global options via CommandRunOptions.Extensions

Modified:

  • Program.cs — complete rewrite using CliHost from the package
  • All 14 input clet files — IClet<T>ICliCommand<T>, CletRunResult<T>CommandResult<T>, etc.
  • All 3 viewer clet files — IViewerCletIViewerCommand
  • MarkdownClet.cs — added RenderCatAsync with error output writing
  • All test files — updated type references
  • CLAUDE.md — updated architecture section
  • README.md — updated clet list --jsonclet --opencli

Design decisions

  • Clet-specific global options (--allow-file, --allow-binary, --no-browse): registered as GlobalOptionDescriptor in CliHost configuration, accessed via CommandRunOptions.Extensions dictionary with helpers in CletOptionsExtensions.
  • --opencli replaces clet list --json for machine-readable command manifest (package-provided).
  • help is now a TUI command provided by the package (was previously HelpClet rendering embedded markdown).

Test results

  • Unit: 311/311 ✓
  • Integration: 54/54 ✓ (2 skipped)
  • Config: 26/26 ✓
  • Smoke: 14/14 ✓ (1 skipped — TUIcast-dependent)
  • UI: 19/19 ✓

Spec/doc impact

  • CLAUDE.md architecture section updated to reflect new structure
  • README.md updated for --opencli usage
  • specs/clet-spec.md — needs follow-up update for infrastructure section (will reference package instead of internal types)

Resolves #180

Replace clet's internal Abstractions/, Registry/, Json/, and Hosting
infrastructure (CommandLineRoot, AliasDispatcher, OutputFormatter,
ExitCodes, etc.) with the Terminal.Gui.Cli NuGet package (0.1.0-develop.2).

Key changes:
- Add Terminal.Gui.Cli 0.1.0-develop.2 PackageReference
- Delete src/Clet/Abstractions/, Registry/, Json/ directories
- Delete hosting files replaced by CliHost (CommandLineRoot, AliasDispatcher,
  OutputFormatter, ExitCodes, CletTypeNames, TerminalEscapeSanitizer,
  MarkdownHelpRenderer, HelpClet)
- Rewrite Program.cs to use CliHost from the package
- Create BuiltInCommands.cs, CletHelpProvider.cs, CletOptionsExtensions.cs
- Update all 14 input clets and 3 viewer clets to use package types
  (ICliCommand<T>, CommandResult<T>, CommandStatus, CommandRunOptions)
- Clet-specific options (--allow-file, --allow-binary, --no-browse)
  registered as GlobalOptionDescriptor, accessed via Extensions dictionary
- Delete 7 unit test files for package-owned infrastructure
- Update all remaining test files for new type names
- Update CLAUDE.md architecture section and README.md

Resolves #180

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6254bfda6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Clet/Clets/Viewer/MarkdownClet.cs Outdated
Comment thread src/Clet/Clets/Viewer/MarkdownClet.cs Outdated
Comment thread src/Clet/Hosting/Program.cs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates clet from its in-repo CLI/hosting implementation to the external Terminal.Gui.Cli NuGet package, making clet primarily a consumer that registers commands and customizes help/options.

Changes:

  • Replaced the internal CLI host/parser/dispatcher/result-writer stack with Terminal.Gui.Cli (CliHost, registries, result/envelope writing, exit codes).
  • Updated all input/viewer commands and test suites to the new Terminal.Gui.Cli command abstractions (ICliCommand, IViewerCommand, CommandRunOptions, CommandResult).
  • Added small hosting glue: BuiltInCommands registration, CletHelpProvider, and CletOptionsExtensions for clet-specific global options.

Reviewed changes

Copilot reviewed 92 out of 92 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Clet.UnitTests/TimeCletTests.cs Updates unit tests to Terminal.Gui.Cli types (CommandKind, ICliCommand).
tests/Clet.UnitTests/TextCletTests.cs Updates unit tests to Terminal.Gui.Cli types.
tests/Clet.UnitTests/TerminalEscapeSanitizerTests.cs Removes tests for deleted internal sanitizer (now expected from package).
tests/Clet.UnitTests/SelectCletTests.cs Updates kind assertions to CommandKind.
tests/Clet.UnitTests/SchemaV1Tests.cs Removes tests for deleted internal JSON envelope.
tests/Clet.UnitTests/PickFileCletTests.cs Updates tests to ICliCommand and CommandKind.
tests/Clet.UnitTests/PickDirectoryCletTests.cs Updates tests to ICliCommand and CommandKind.
tests/Clet.UnitTests/OutputFormatterTests.cs Removes tests for deleted internal output formatting.
tests/Clet.UnitTests/MultiSelectCletTests.cs Updates kind assertion to CommandKind.
tests/Clet.UnitTests/MarkdownContentResolverTests.cs Ports tests to CommandRunOptions + global-option extensions dictionary.
tests/Clet.UnitTests/MarkdownCletTests.cs Updates viewer kind assertion to CommandKind.Viewer.
tests/Clet.UnitTests/LinearRangeCletTests.cs Ports to CommandRunOptions/CommandResult/CommandStatus.
tests/Clet.UnitTests/IntCletTests.cs Ports to CommandRunOptions and new result/status types.
tests/Clet.UnitTests/ExitCodesTests.cs Ports to package CommandResult/CommandStatus for exit mapping tests.
tests/Clet.UnitTests/DurationCletTests.cs Updates tests to Terminal.Gui.Cli types.
tests/Clet.UnitTests/DecimalCletTests.cs Updates tests to Terminal.Gui.Cli types.
tests/Clet.UnitTests/DateCletTests.cs Updates tests to Terminal.Gui.Cli types.
tests/Clet.UnitTests/ConfirmCletTests.cs Updates tests to Terminal.Gui.Cli types.
tests/Clet.UnitTests/CommandLineRootTests.cs Removes tests for deleted internal CLI root/parser.
tests/Clet.UnitTests/ColorCletTests.cs Ports to CommandRunOptions and ICliCommand.
tests/Clet.UnitTests/CletTypeNamesTests.cs Removes tests for deleted internal type-name mapping helper.
tests/Clet.UnitTests/CletRunResultTests.cs Removes tests for deleted internal result types.
tests/Clet.UnitTests/CletRegistryTests.cs Removes tests for deleted internal registry.
tests/Clet.UnitTests/CletMetadataTests.cs Ports metadata tests to Terminal.Gui.Cli command interfaces/kinds.
tests/Clet.UnitTests/BuiltInCletsTests.cs Updates to BuiltInCommands + package CommandRegistry.
tests/Clet.UnitTests/AttributePickerCletTests.cs Ports to ICliCommand and CommandKind.
tests/Clet.UITests/CletUiTests.cs Ports UI harness usage to CommandRunOptions and new interfaces.
tests/Clet.UITests/CletUiHarness.cs Ports harness result plumbing to CommandResult.
tests/Clet.SmokeTests/CletSmokeTests.cs Updates smoke tests for --opencli, new --version format, and new error expectations.
tests/Clet.IntegrationTests/TimeCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/TextCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/SelectCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/PickFileCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/PickDirectoryCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/MultiSelectCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/MarkdownCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult and global extensions for --no-browse.
tests/Clet.IntegrationTests/LinearRangeCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/IntCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/DurationCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/DecimalCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/DateCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/ConfirmCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/ConfigCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/ColorCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
tests/Clet.IntegrationTests/AttributePickerCletIntegrationTests.cs Ports integration tests to CommandRunOptions/CommandResult.
src/Clet/Registry/CletRegistry.cs Deletes internal registry (replaced by package CommandRegistry).
src/Clet/Json/SchemaV1.cs Deletes internal JSON envelope type (replaced by package).
src/Clet/Json/CletJsonContext.cs Deletes internal JSON source-gen context (replaced by package).
src/Clet/Hosting/TerminalEscapeSanitizer.cs Deletes internal sanitizer (expected from package).
src/Clet/Hosting/Program.cs Rewrites entrypoint to configure and run CliHost + register global options.
src/Clet/Hosting/OutputFormatter.cs Deletes internal output writer (replaced by package).
src/Clet/Hosting/MarkdownHelpRenderer.cs Deletes internal markdown-to-ANSI help renderer (replaced by package).
src/Clet/Hosting/MarkdownContentResolver.cs Ports resolver to CommandRunOptions + clet global-option extensions helpers.
src/Clet/Hosting/ExitCodes.cs Deletes internal exit code mapping (replaced by package).
src/Clet/Hosting/CommandLineRoot.cs Deletes internal argument parser/dispatcher root (replaced by package).
src/Clet/Hosting/CletTypeNames.cs Deletes internal wire-name mapping (now package/opencli-driven).
src/Clet/Hosting/CletOptionsExtensions.cs Adds helpers for reading clet global options from CommandRunOptions.Extensions.
src/Clet/Hosting/CletHelpProvider.cs Adds custom help provider that injects the command table and version into embedded markdown.
src/Clet/Hosting/BuiltInCommands.cs Replaces BuiltInClets with package registry-based command registration.
src/Clet/Hosting/AliasDispatcher.cs Deletes internal dispatcher (replaced by package).
src/Clet/Clets/Viewer/MarkdownClet.cs Ports markdown viewer to IViewerCommand, adds RenderCatAsync, and switches option sources.
src/Clet/Clets/Viewer/HelpClet.cs Deletes internal help viewer command (replaced by package built-in help).
src/Clet/Clets/Viewer/EditorClet.cs Ports editor viewer to IViewerCommand/CommandResult and global options extensions.
src/Clet/Clets/Viewer/ConfigClet.cs Ports config viewer to IViewerCommand/CommandResult.
src/Clet/Clets/Input/TimeClet.cs Ports input command to ICliCommand<T> and new result/status types.
src/Clet/Clets/Input/TextClet.cs Ports input command to ICliCommand<T> and new result/status types.
src/Clet/Clets/Input/SelectClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/PickFileClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/PickDirectoryClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/MultiSelectClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/LinearRangeClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/IntClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/InputCletRunner.cs Ports shared runner to return CommandResult<T> and accept CommandRunOptions.
src/Clet/Clets/Input/DurationClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/DecimalClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/DateClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/ConfirmClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/ColorClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clets/Input/AttributePickerClet.cs Ports input command and updates options plumbing to CommandRunOptions.
src/Clet/Clet.csproj Adds Terminal.Gui.Cli package reference.
src/Clet/Abstractions/IViewerClet.cs Deletes internal viewer abstraction (replaced by package).
src/Clet/Abstractions/ICletRegistry.cs Deletes internal registry abstraction (replaced by package).
src/Clet/Abstractions/IClet.cs Deletes internal command abstraction (replaced by package).
src/Clet/Abstractions/CletRunStatus.cs Deletes internal status enum (replaced by package).
src/Clet/Abstractions/CletRunResult.cs Deletes internal result types (replaced by package).
src/Clet/Abstractions/CletRunOptions.cs Deletes internal options type (replaced by package).
src/Clet/Abstractions/CletOptionDescriptor.cs Deletes internal option descriptor type (replaced by package).
src/Clet/Abstractions/CletKind.cs Deletes internal kind enum (replaced by package).
src/Clet/Abstractions/BoxedCletResult.cs Deletes internal boxed result type (replaced by package).
README.md Updates docs for clet help and --opencli manifest discovery.
Directory.Build.props Adds pinned TerminalGuiCliVersion property.
CLAUDE.md Updates architecture notes to reflect the new Terminal.Gui.Cli-based hosting model.
Comments suppressed due to low confidence (1)

src/Clet/Clets/Viewer/MarkdownClet.cs:31

  • MarkdownClet defines a command option named no-browse, but Program.Main also registers no-browse as a global option and the implementation reads it via options.GetNoBrowse() (Extensions). Having both a command option and a global option with the same name is likely to cause parsing conflicts or the flag being stored in the wrong place (CommandOptions vs Extensions), so --no-browse may not work reliably. Drop the no-browse entry from MarkdownClet.Options (and document it as global), or remove the global option and read it from options.CommandOptions consistently.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Clet/Clets/Viewer/MarkdownClet.cs Outdated
Comment thread src/Clet/Hosting/CletHelpProvider.cs
Comment thread src/Clet/Hosting/Program.cs Outdated
tig and others added 2 commits May 25, 2026 13:48
- RenderCatAsync now passes options.Initial to content resolution,
  restoring --initial support in --cat mode
- RenderCatAsync uses resolved.Content directly instead of re-reading
  only the first file, fixing multi-file concatenation
- CletHelpProvider normalizes legacy clet:help: scheme to help:
- Remove unused using System.Reflection from Program.cs
- Add tests for RenderCatAsync initial content and multi-file rendering
- Add test for help provider link scheme normalization
- Document input-too-large exit code package limitation in ExitCodesTests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tig tig merged commit e7b907c into develop May 27, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt Terminal.Gui.Cli package once gui-cs/cli is published

2 participants