Skip to content

Add version command line option#3097

Merged
MrHinsh merged 5 commits intonkdAgility:mainfrom
sbouchexbellomie-Philips:copilot/add-version-command-line-option
Jan 21, 2026
Merged

Add version command line option#3097
MrHinsh merged 5 commits intonkdAgility:mainfrom
sbouchexbellomie-Philips:copilot/add-version-command-line-option

Conversation

@sbouchexbellomie-Philips
Copy link
Contributor

@sbouchexbellomie-Philips sbouchexbellomie-Philips commented Jan 19, 2026

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

    • Added a new "version" command to display the tool's running version; includes Git metadata (tag, branch, commits) for pre-release builds.
  • Bug Fixes

    • Corrected a logging typo in version output.
  • Tests

    • Added tests validating the version command and service resolution.
  • Chores

    • Test project now ensures configuration file is included in test run outputs.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI and others added 4 commits January 19, 2026 10:10
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>
@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

Walkthrough

Adds a new version CLI command (implementation and settings), registers it in the host, adds tests and test project content, and fixes a typo in a log message. Tests resolve and exercise IMigrationToolVersion.GetRunningVersion().

Changes

Cohort / File(s) Summary
Version Command Implementation
src/MigrationTools.Host/Commands/VersionCommand.cs, src/MigrationTools.Host/Commands/VersionCommandSettings.cs
New internal VersionCommand that resolves IMigrationToolVersion, calls GetRunningVersion(), writes version string (and Git metadata when Major == 0) to console. Settings class added (empty, derives from CommandSettingsBase).
CLI Registration
src/MigrationTools.Host/MigrationToolHost.cs
Registers the version command via config.AddCommand<Commands.VersionCommand>("version") with description and example.
Tests & Test Project
src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs, src/MigrationTools.Host.Tests/MigrationTools.Host.Tests.csproj
New MSTest class VersionCommandTests with Setup/Cleanup and two tests: service resolution and GetRunningVersion() assertions. Project file updated to include appsettings.json as content copied to output.
Minor Fix
src/MigrationTools.Host/Commands/CommandBase.cs
Corrected logging typo from "Verion Info:" to "Version Info:".

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A new flag whispers version true,
It asks the host what it can do,
DI wakes, the service speaks,
Console prints the info we seek—
Tests nod, the typo bids adieu.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add version command line option' accurately describes the main change: introducing a new CLI command to display the tool's version.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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(...) (or AnsiConsole.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)}");
     }

@MrHinsh MrHinsh merged commit 86ce965 into nkdAgility:main Jan 21, 2026
12 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.

3 participants