Replace Spectre.Console.Cli with bv's own CLI layer - #279
Conversation
…re.Execution Unclutter the overloaded Cli namespace by extracting cohesive groups: - Buildvana.Tool.Commands: the command classes plus their settings (BaseSettings, ReleaseSettings, GlobalOptions) and BuildSteps. - Buildvana.Tool.CommandLine: ForwardedArguments (the parsing primitives follow in the next commit). - Buildvana.Tool.Infrastructure.Execution: command discovery and dispatch (ImplementsCommandAttribute, CommandRegistration, CommandRegistry). The Spectre.Console.Cli glue (BvHelpProvider, TypeRegistrar, TypeResolver) stays in Cli pending its removal. Behavior-preserving: Spectre still drives parsing and dispatch. GitService aliases LibGit2Sharp.Commands so the new Commands namespace no longer shadows it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Introduce the hand-rolled command-line layer in Buildvana.Tool.CommandLine, not yet wired into Program (Spectre still runs the show): - BvOptionAttribute: template-parsed option help metadata. - CliOptionReader: long/short names, '=' and space forms, case-insensitive, with leftover-token detection for strict commands. - CliArgSplitter + ParsedCommandLine: split on '--', strip globals/help, then classify the residue into subcommand, positionals, and option tokens. Add the repo's first test project, tests/Buildvana.Tool.Tests, on TUnit and the Microsoft Testing Platform (29 tests over the reader and splitter). Pin TUnit and the MTP code-coverage extension centrally, register the project in the solution, grant InternalsVisibleTo from Buildvana.Tool, and select the MTP test runner in global.json. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drop the Spectre.Console.Cli dependency and own the command-line parsing, dispatch, and help rendering. Spectre.Console proper (AnsiConsole, markup, SpectreLogger) stays as the console backbone. - Program builds its DI container directly and dispatches without Spectre: CliArgSplitter parses the line, CommandRegistry resolves the command, and the IBvCommand is resolved from the container and executed. - Commands implement IBvCommand instead of AsyncCommand<TSettings>; the release command has its ReleaseSettings injected, parsed from the arg-bag with unknown options rejected. - Merge GlobalOptions and BaseSettings into GlobalSettings, which carries both the parsed global values and the [BvOption]/[Description] help metadata. - Generalize ForwardedArguments into CommandParameters (Options + Forwarded). - Render help with BvHelpRenderer over Spectre.Console grids, reflecting the [BvOption] metadata on GlobalSettings and each command's settings type. - CommandArgumentValidator enforces the new `--` forwarding rule: forwarding commands accept nothing before `--`; non-forwarding commands reject anything after it. This replaces the old both-sides forwarding heuristic. - Wire Console.CancelKeyPress to a CancellationToken handed to ExecuteAsync. - Delete TypeRegistrar, TypeResolver, BvHelpProvider, BaseSettings, and GlobalOptions; drop the Spectre.Console.Cli package reference and version. Cover the new pieces with tests for ReleaseSettings parsing, argument validation, command lookup, and settings help reflection (47 tests total). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Spectre.Console.Cli's DI forced command, settings, and service types to be public. With Spectre gone, make every type in Buildvana.Tool internal (services, settings, helpers, records, enums); the test project reaches them through InternalsVisibleTo. Keep the CA1515 NoWarn: with no public types left, Roslyn still reports a single locationless CA1515 (a false positive against a synthesized type). Re-documented; revisit when the analyzers are updated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Commands namespace shadowed LibGit2Sharp.Commands in GitService (worked around with a GitCommands alias) and read awkwardly beside the rest of the command infrastructure. "Subcommands" is unambiguous and more accurate: clean, build, restore, etc. are subcommands of bv. Rename the namespace and drop the now-unnecessary GitCommands alias, restoring the plain Commands.Stage call. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The pipeline forwarding and -c/--configuration bullets described the interim both-sides behavior. Update them for the -- separator rule: pipeline commands forward only after --, option-looking tokens before -- error, and bv release rejects -- outright. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@claude please review this PR. |
|
Claude finished @rdeago's task in 5m 39s —— View job PR Review
Overall this is a clean, well-structured migration. The layering is clear ( 1. Stale "Spectre commands" in
|
Closes #278.
Removes the
Spectre.Console.Clidependency and replaces it with bv's own command-line parsing, dispatch, and help rendering.Spectre.Consoleproper (markup,AnsiConsole, the logger) stays as the console backbone.What's in here (commit by commit)
Clinamespace intoCommands,CommandLine, andInfrastructure.Execution.CliArgSplitter,CliOptionReader,BvOptionAttribute,ParsedCommandLine, plustests/Buildvana.Tool.Tests(TUnit on Microsoft.Testing.Platform — the repo's first test project).CommandRegistry+IBvCommand),GlobalSettings(merging the old globals + base settings),BvHelpRenderer, the--forwarding rule,Console.CancelKeyPresswiring; deletes the Spectre adapters and drops theSpectre.Console.Clipackage.Commands→Subcommands(it shadowedLibGit2Sharp.Commands).-cbullets for the--separator.Behavior change
The only intentional user-facing change is
--forwarding:bv build/restore/test/packforward only what follows--(e.g.bv build -- -p:Foo=Bar); option-looking tokens before--now error and point at the separator.bv releaserejects--. The rest of the option surface is behavior-preserving.Test plan
dotnet bv pack— clean (Release build + tests + artifacts).ReleaseSettings, argument validation, command lookup, help reflection).inspectcode --severity=WARNING— 0 results.bv: root/per-command help,--version, and the--/unknown-option/unknown-command error paths (correct messages + exit codes).