Skip to content

Add CLI command to display version with a random quote - #37

Merged
evgenyk merged 1 commit into
mainfrom
ev/cli_about_jokes
Sep 8, 2025
Merged

Add CLI command to display version with a random quote#37
evgenyk merged 1 commit into
mainfrom
ev/cli_about_jokes

Conversation

@evgenyk

@evgenyk evgenyk commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

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.

- 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.
@coderabbitai

coderabbitai Bot commented Sep 8, 2025

Copy link
Copy Markdown

Walkthrough

Adds 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

Cohort / File(s) Summary
Version command enhancements
examples/cli/pkg/cmd/version.go
Inserted random quote box after version print and before existing flow; added imports (math/rand, strings, time, unicode/utf8); no exported signature changes; control flow otherwise unchanged.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ev/cli_about_jokes

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 480a00c and 6a97007.

⛔ Files ignored due to path filters (1)
  • .vscode/launch.json is 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.Seed and keeping scope local.

Comment thread examples/cli/pkg/cmd/version.go
@evgenyk
evgenyk merged commit 48db2aa into main Sep 8, 2025
4 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.

1 participant