File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ package cli
22
33import (
44 "github.com/spf13/cobra"
5+
6+ "github.com/kernelshard/expose/internal/version"
57)
68
79var rootCmd = & cobra.Command {
8- Use : "expose" ,
9- Short : "Expose localhost to the internet" ,
10- Long : "Minimal CLI to expose your local dev server" ,
10+ Use : "expose" ,
11+ Short : "Expose localhost to the internet" ,
12+ Long : "Minimal CLI to expose your local dev server" ,
13+ Version : version .GetFullVersion (),
1114}
1215
1316func Execute () error {
Original file line number Diff line number Diff line change 1+ package version
2+
3+ var (
4+ Version = "v0.1.1"
5+ GitCommit = "1c064a2"
6+ BuildDate = "2025-11-07"
7+ )
8+
9+ // GetVersion returns just the version string
10+ func GetVersion () string {
11+ if Version == "dev" {
12+ return "dev (unreleased)"
13+ }
14+ return Version
15+ }
16+
17+ // GetFullVersion returns version with build metadata (for Cobra)
18+ // Note: Cobra automatically prefixes with "expose version"
19+ func GetFullVersion () string {
20+ return GetVersion () + " (commit: " + GitCommit + ", built: " + BuildDate + ")"
21+ }
Original file line number Diff line number Diff line change 1+ package version
2+
3+ import (
4+ "strings"
5+ "testing"
6+ )
7+
8+ func TestGetVersion (t * testing.T ) {
9+ v := GetVersion ()
10+ if ! strings .Contains (v , Version ) {
11+ t .Errorf ("GetVersion mismatch expected %s in:%s" , Version , v )
12+ }
13+ }
14+
15+ func TestGetFullVersion (t * testing.T ) {
16+ fullVersion := GetFullVersion ()
17+ if ! strings .Contains (fullVersion , GitCommit ) {
18+ t .Errorf ("GetFullVersion call expected %s in %s" , GitCommit , fullVersion )
19+ }
20+ if ! strings .Contains (fullVersion , BuildDate ) {
21+ t .Errorf ("GetFullVersion call expected %s in %s" , BuildDate , fullVersion )
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments