Skip to content

Commit 48db2aa

Browse files
authored
Merge pull request #37 from kinde-oss/ev/cli_about_jokes
Add CLI command to display version with a random quote
2 parents 480a00c + 6a97007 commit 48db2aa

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
"KINDE_KEYCHAIN_PASS": "some_super_secret"
4343
}
4444
},
45+
{
46+
"name": "Launch example CLI - version",
47+
"type": "go",
48+
"request": "launch",
49+
"mode": "auto",
50+
"program": "${workspaceFolder}/examples/cli/cmd/example-cli",
51+
"args": ["version"]
52+
},
4553
{
4654
"name": "Launch example CLI - logout",
4755
"type": "go",

examples/cli/pkg/cmd/version.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package cmd
22

33
import (
44
"fmt"
5+
"math/rand"
6+
"strings"
7+
"time"
8+
"unicode/utf8"
59

610
"github.com/kinde-oss/kinde-cli/pkg/release"
711
"github.com/spf13/cobra"
@@ -19,6 +23,32 @@ func newVersionCmd() *versionCmd {
1923
Short: "Version",
2024
Run: func(cmd *cobra.Command, args []string) {
2125
fmt.Printf("version %v\n", release.Branch)
26+
// --- NEW: print a random quote using a local RNG ---
27+
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
28+
quotes := []string{
29+
"Authentication is like a password for your soul – if you forget it, the universe will ask for a reset.",
30+
"Billing: because even the most powerful APIs need to pay their bills in code.",
31+
"Feature flags are the adult version of 'Did you finish your homework?' – they keep us honest.",
32+
"Why did the developer go broke? Because he kept enabling all feature flags and forgot to bill his clients!",
33+
"If authentication fails, just blame it on the network. If billing fails, blame it on the accountant. Feature flags? Blame them for being too flexible.",
34+
"Authentication is a lot like a good joke – if you don't get it, nobody will laugh.",
35+
"Billing is the only place where you can finally say 'I’m not kidding' and still be taken seriously.",
36+
"Feature flags: because sometimes you need to turn features on and off faster than your coffee machine.",
37+
"Authentication is the only place where a typo can cost you more than a typo in your code.",
38+
"Billing: the art of turning your customers’ money into a line of code.",
39+
"Feature flags are like mood rings – they change depending on what you want to show.",
40+
}
41+
// Build an ASCII box around the selected quote
42+
selected := quotes[rng.Intn(len(quotes))]
43+
// Use rune count to account for Unicode characters
44+
width := utf8.RuneCountInString(selected)
45+
border := "┌" + strings.Repeat("─", width+2) + "┐"
46+
middle := fmt.Sprintf("│ %s │", selected)
47+
bottom := "└" + strings.Repeat("─", width+2) + "┘"
48+
fmt.Println(border)
49+
fmt.Println(middle)
50+
fmt.Println(bottom)
51+
// -----------------------------------
2252
release.IsNeedingUpdate()
2353
},
2454
},

0 commit comments

Comments
 (0)