Adopt Terminal.Gui.Cli package, replacing internal CLI infrastructure#185
Conversation
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>
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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.Clicommand abstractions (ICliCommand,IViewerCommand,CommandRunOptions,CommandResult). - Added small hosting glue:
BuiltInCommandsregistration,CletHelpProvider, andCletOptionsExtensionsfor 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
MarkdownCletdefines a command option namedno-browse, butProgram.Mainalso registersno-browseas a global option and the implementation reads it viaoptions.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-browsemay not work reliably. Drop theno-browseentry fromMarkdownClet.Options(and document it as global), or remove the global option and read it fromoptions.CommandOptionsconsistently.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 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>
Summary
Replaces clet's internal CLI hosting infrastructure with the
Terminal.Gui.CliNuGet 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,BoxedCletResultsrc/Clet/Registry/—CletRegistry,BuiltInCletssrc/Clet/Json/—SchemaV1,CletJsonContextsrc/Clet/Hosting/—CommandLineRoot,AliasDispatcher,OutputFormatter,ExitCodes,CletTypeNames,TerminalEscapeSanitizer,MarkdownHelpRenderersrc/Clet/Clets/Viewer/HelpClet.cs— replaced by package's built-inhelpcommandCreated:
src/Clet/Hosting/BuiltInCommands.cs— static registration helper for all 17 commandssrc/Clet/Hosting/CletHelpProvider.cs— customIHelpProviderimplementationsrc/Clet/Hosting/CletOptionsExtensions.cs— extension methods for accessing clet-specific global options viaCommandRunOptions.ExtensionsModified:
Program.cs— complete rewrite usingCliHostfrom the packageIClet<T>→ICliCommand<T>,CletRunResult<T>→CommandResult<T>, etc.IViewerClet→IViewerCommandMarkdownClet.cs— addedRenderCatAsyncwith error output writingCLAUDE.md— updated architecture sectionREADME.md— updatedclet list --json→clet --opencliDesign decisions
--allow-file,--allow-binary,--no-browse): registered asGlobalOptionDescriptorinCliHostconfiguration, accessed viaCommandRunOptions.Extensionsdictionary with helpers inCletOptionsExtensions.--openclireplacesclet list --jsonfor machine-readable command manifest (package-provided).helpis now a TUI command provided by the package (was previouslyHelpCletrendering embedded markdown).Test results
Spec/doc impact
CLAUDE.mdarchitecture section updated to reflect new structureREADME.mdupdated for--opencliusagespecs/clet-spec.md— needs follow-up update for infrastructure section (will reference package instead of internal types)Resolves #180