Add CLI command to display version with a random quote - #37
Conversation
- Introduced a new launch configuration in launch.json for the example CLI to run the version command. - Enhanced the version command in version.go to print a random quote in an ASCII box format, adding a fun element to the output.
WalkthroughAdds a random quote box to the version command. After printing the version, it seeds a local RNG with current time, picks a quote from a hard-coded list, computes display width with utf8.RuneCountInString, and prints it in a Unicode box. Existing branch print and update check remain, following the new quote output. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as VersionCmd.Run
participant Release as release
User->>CLI: Invoke `version`
rect rgb(235, 245, 255)
note right of CLI: Existing
CLI->>User: Print version
end
rect rgb(240, 255, 240)
note right of CLI: New
CLI->>CLI: Seed RNG (time.Now)
CLI->>CLI: Select random quote
CLI->>CLI: Compute box width (utf8.RuneCountInString)
CLI->>User: Print Unicode box with quote
end
rect rgb(235, 245, 255)
note right of CLI: Existing
CLI->>User: Print release.Branch
CLI->>Release: IsNeedingUpdate()
alt Update available
CLI->>User: Print update notice
else Up-to-date
CLI->>User: Print up-to-date message
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches
🧪 Generate unit tests
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
🧹 Nitpick comments (1)
examples/cli/pkg/cmd/version.go (1)
44-47: Rune count ≠ display width; consider runewidth for proper box sizing.utf8.RuneCountInString mis-measures grapheme width (emoji, CJK, combining). Use
github.com/mattn/go-runewidth.-import "unicode/utf8" +import "unicode/utf8" +// optional: +// import "github.com/mattn/go-runewidth" -// Use rune count to account for Unicode characters -width := utf8.RuneCountInString(selected) +// Better terminal width (optional dep): +// width := runewidth.StringWidth(selected) +// If avoiding deps, keep utf8.RuneCountInString as a best-effort.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
.vscode/launch.jsonis excluded by!**/*.json
📒 Files selected for processing (1)
examples/cli/pkg/cmd/version.go(2 hunks)
🔇 Additional comments (1)
examples/cli/pkg/cmd/version.go (1)
27-28: Local RNG seeding is fine here.Good choice avoiding global
rand.Seedand keeping scope local.
Introduce a new command in the CLI to display the version along with a randomly selected quote formatted in an ASCII box. Include a launch configuration for easy execution of the new command.