Add version command line option#3097
Conversation
Co-authored-by: sbouchexbellomie-Philips <182072604+sbouchexbellomie-Philips@users.noreply.github.com>
…t cleanup Co-authored-by: sbouchexbellomie-Philips <182072604+sbouchexbellomie-Philips@users.noreply.github.com>
WalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Host as Host / DI
participant Cmd as VersionCommand
participant VerSvc as IMigrationToolVersion
participant Console as AnsiConsole
CLI->>Host: Invoke "version" command
Host->>Cmd: Resolve command (DI)
Cmd->>VerSvc: GetRunningVersion()
VerSvc-->>Cmd: VersionInfo (versionString, git metadata)
Cmd->>Console: Write versionString
alt Major == 0
Cmd->>Console: Write Tag / Branch / Commits
end
Cmd-->>CLI: Exit (0)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/MigrationTools.Host/Commands/VersionCommand.cs`:
- Around line 35-56: The ExecuteInternalAsync method in VersionCommand.cs
currently catches all exceptions and calls CommandActivity.RecordException then
returns a failure code, which bypasses CommandBase's centralized
logging/telemetry; remove the local try/catch (or if you prefer keep try for
flow, rethrow the caught exception instead of swallowing it) in
ExecuteInternalAsync so exceptions propagate to the base; specifically update
ExecuteInternalAsync (and remove the CommandActivity.RecordException call) so
failures are thrown up to the base handler rather than returning
Task.FromResult(1).
🧹 Nitpick comments (1)
src/MigrationTools.Host/Commands/VersionCommand.cs (1)
41-47: Escape dynamic content before MarkupLine to avoid parse errors.Version and Git strings may include markup tokens; Spectre.Console will throw on invalid markup. Use
Markup.Escape(...)(orAnsiConsole.WriteLine) to keep output robust.Suggested fix
- AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {versionInfo.versionString}"); + AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {Markup.Escape(versionInfo.versionString)}"); if (versionInfo.version.Major == 0) { - AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {ThisAssembly.Git.Tag}"); - AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {ThisAssembly.Git.Branch}"); - AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {ThisAssembly.Git.Commits}"); + AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {Markup.Escape(ThisAssembly.Git.Tag)}"); + AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {Markup.Escape(ThisAssembly.Git.Branch)}"); + AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {Markup.Escape(ThisAssembly.Git.Commits)}"); }
Idea : Being able to get the version of the tool without doing a migration but rather by using the "version" command line tool option
Generated with copilot
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores
✏️ Tip: You can customize this high-level summary in your review settings.