Skip to content

feat(cli): add --version and -v support#8

Merged
satococoa merged 2 commits intomainfrom
codex/add-version-flags
Mar 5, 2026
Merged

feat(cli): add --version and -v support#8
satococoa merged 2 commits intomainfrom
codex/add-version-flags

Conversation

@satococoa
Copy link
Copy Markdown
Owner

@satococoa satococoa commented Mar 5, 2026

Summary

  • wire root command Version in urfave/cli
  • enable built-in --version / -v output
  • add unit and integration tests for version flags
  • inject release version via Goreleaser ldflags
  • document version flag usage in README

Testing

  • go test ./...
  • go run ./cmd/git-worktreeinclude --version
  • go run ./cmd/git-worktreeinclude -v

Summary by CodeRabbit

  • New Features

    • Implemented version flag support (--version and -v) for the CLI tool, allowing users to view the current application version.
  • Documentation

    • Updated README to document the version flag feature with usage examples and expected output.
  • Tests

    • Added tests to verify version flag functionality and output format consistency.

Copilot AI review requested due to automatic review settings March 5, 2026 16:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

@satococoa Sure, I'll review the changes in this PR now!

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 5, 2026

@satococoa I've opened a new pull request, #9, to work on those changes. Once the pull request is ready, I'll request review from you.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6ea88197-7c7b-45b9-b36b-27e3f3701948

📥 Commits

Reviewing files that changed from the base of the PR and between 7678c66 and 9393d8a.

📒 Files selected for processing (1)
  • internal/cli/cli_unit_test.go

📝 Walkthrough

Walkthrough

Adds a build-time injectable Version variable, exposes it on the CLI root command (supporting --version and -v), updates goreleaser to set the value at link time, and adds unit and integration tests plus README documentation for the flag.

Changes

Cohort / File(s) Summary
Build config
\.goreleaser\.yml
Adds an ldflag (-X ...) to inject the internal/cli.Version value at link time.
CLI implementation
internal/cli/cli.go
Introduces var Version = "dev" and sets the root command's Version field to this variable.
Tests
internal/cli/cli_integration_test.go, internal/cli/cli_unit_test.go
Adds TestRootVersionFlags (integration) and TestRunRootVersion (unit) to verify --version and -v outputs, exit codes, and stdout/stderr behavior.
Documentation
README.md
Adds documentation and examples for --version / -v usage and sample output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble a flag into the tree,
A build-time name sewn proudly on me,
Tests hop around to make it right,
Docs sing the version into the light,
Cheers for the tag — a tiny release delight!

🚥 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 PR title clearly and concisely summarizes the main change: adding --version and -v flag support to the CLI.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-version-flags

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
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 adds --version / -v flag support to the git-worktreeinclude CLI by wiring in urfave/cli's built-in version mechanism, injecting the release version string at build time via goreleaser ldflags, and adding documentation and test coverage for both flags.

Changes:

  • Wire Version package-level variable into urfave/cli's Command.Version field, enabling built-in --version and -v output
  • Inject version at build time via goreleaser ldflags and default to "dev" for local builds
  • Add unit and integration tests for version flag behavior, and document the flags in README

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/cli/cli.go Adds var Version = "dev" global and wires it into newRootCommand()'s Version field
internal/cli/cli_unit_test.go Adds TestRunRootVersion testing --version output and stdout/stderr correctness
internal/cli/cli_integration_test.go Adds TestRootVersionFlags looping over --version and -v, verifying output format against the built binary
.goreleaser.yml Extends ldflags to inject the release version into internal/cli.Version
README.md Adds --version / -v command section under the Commands heading


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

@satococoa
Copy link
Copy Markdown
Owner Author

Addressed Copilot feedback in 9393d8a: TestRunRootVersion now validates both --version and -v.

@satococoa satococoa merged commit ada03ed into main Mar 5, 2026
5 checks passed
@satococoa satococoa deleted the codex/add-version-flags branch March 5, 2026 16:19
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