Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: goreleaser

on:
pull_request:
push:
# run only against tags
tags:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.PHONY: build
build:
go build -o out/shell-now ./cmd/shell-now/
go build -ldflags "-X main.version=$(shell git describe --tags --always --dirty) -X main.commit=$(shell git rev-parse HEAD) -X main.buildTime=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)" -o out/shell-now ./cmd/shell-now/
24 changes: 22 additions & 2 deletions cmd/shell-now/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"log/slog"
"os"
"os/signal"
Expand All @@ -11,6 +12,12 @@ import (
"github.com/strrl/shell-now/pkg"
)

var (
version = "dev"
commit = "unknown"
buildTime = "unknown"
)

func main() {

if os.Getenv("DEBUG") != "" {
Expand All @@ -25,8 +32,9 @@ func main() {
defer stop()

rootCmd := &cobra.Command{
Use: "shell-now",
Short: "Shell Now is a simple command-line tool to expose your local shell to the public internet.",
Use: "shell-now",
Short: "Shell Now is a simple command-line tool to expose your local shell to the public internet.",
Version: version,
RunE: func(cmd *cobra.Command, args []string) error {
return pkg.Bootstrap(ctx)
},
Expand Down Expand Up @@ -93,6 +101,18 @@ PowerShell:
}
rootCmd.AddCommand(completionCmd)

// Add version command
versionCmd := &cobra.Command{
Use: "version",
Short: "Print the version information of shell-now",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("shell-now version %s\n", version)
fmt.Printf("git commit: %s\n", commit)
fmt.Printf("build time: %s\n", buildTime)
},
}
rootCmd.AddCommand(versionCmd)

// Execute with context
if err := rootCmd.ExecuteContext(ctx); err != nil {
os.Exit(1)
Expand Down