Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package cli

import (
"github.com/spf13/cobra"

"github.com/kernelshard/expose/internal/version"
)

var rootCmd = &cobra.Command{
Use: "expose",
Short: "Expose localhost to the internet",
Long: "Minimal CLI to expose your local dev server",
Use: "expose",
Short: "Expose localhost to the internet",
Long: "Minimal CLI to expose your local dev server",
Version: version.GetFullVersion(),
}

func Execute() error {
Expand Down
21 changes: 21 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package version

var (
Version = "v0.1.1"
GitCommit = "4784595"
BuildDate = "2025-11-07"
)

// GetVersion returns just the version string
func GetVersion() string {
if Version == "dev" {
return "dev (unreleased)"
}
return Version
}

// GetFullVersion returns version with build metadata (for Cobra)
// Note: Cobra automatically prefixes with "expose version"
func GetFullVersion() string {
return GetVersion() + " (commit: " + GitCommit + ", built: " + BuildDate + ")"
}
23 changes: 23 additions & 0 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package version

import (
"strings"
"testing"
)

func TestGetVersion(t *testing.T) {
v := GetVersion()
if !strings.Contains(v, Version) {
t.Errorf("GetVersion mismatch expected %s in:%s", Version, v)
}
}

func TestGetFullVersion(t *testing.T) {
fullVersion := GetFullVersion()
if !strings.Contains(fullVersion, GitCommit) {
t.Errorf("GetFullVersion call expected %s in %s", GitCommit, fullVersion)
}
if !strings.Contains(fullVersion, BuildDate) {
t.Errorf("GetFullVersion call expected %s in %s", BuildDate, fullVersion)
}
}