summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2023-08-18 13:51:06 -0700
committerMike Crute <mike@crute.us>2023-08-18 13:51:06 -0700
commitaa0254d2eb8cfb89d594861dcb3c9af2b0cf2b89 (patch)
treed280d83df6a0cbda5eb21de30601d2312f8e8413
parenta0328f36938dc2f78e9c1df0735edb8d16528d39 (diff)
downloadwebsocket_proxy-aa0254d2eb8cfb89d594861dcb3c9af2b0cf2b89.tar.bz2
websocket_proxy-aa0254d2eb8cfb89d594861dcb3c9af2b0cf2b89.tar.xz
websocket_proxy-aa0254d2eb8cfb89d594861dcb3c9af2b0cf2b89.zip
Simplify main and version
-rw-r--r--Makefile4
-rw-r--r--clientmain.go4
-rw-r--r--cmd/client/client.go7
-rw-r--r--main.go6
4 files changed, 11 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 99748de..339b5c8 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ $(SERVER_BINARY): $(SERVER_FILES)
9 @mkdir clients/ || true 9 @mkdir clients/ || true
10 @touch clients/keep 10 @touch clients/keep
11 CGO_ENABLED=0 go build \ 11 CGO_ENABLED=0 go build \
12 -ldflags "-X main.appVersion=$(shell git describe --long --tags --dirty --always) \ 12 -ldflags "-X main.version=$(shell git describe --long --tags --dirty --always) \
13 -X code.crute.us/mcrute/ssh-proxy/cmd/client.clientId=$(CLIENT_ID)" \ 13 -X code.crute.us/mcrute/ssh-proxy/cmd/client.clientId=$(CLIENT_ID)" \
14 -o $@ 14 -o $@
15 15
@@ -19,7 +19,7 @@ client:
19 19
20 CGO_ENABLED=0 go build \ 20 CGO_ENABLED=0 go build \
21 -tags clientonly \ 21 -tags clientonly \
22 -ldflags "-X main.appVersion=$(shell git describe --long --tags --dirty --always) \ 22 -ldflags "-X main.version=$(shell git describe --long --tags --dirty --always) \
23 -X code.crute.us/mcrute/ssh-proxy/cmd/client.clientId=$(CLIENT_ID) \ 23 -X code.crute.us/mcrute/ssh-proxy/cmd/client.clientId=$(CLIENT_ID) \
24 -s -w" \ 24 -s -w" \
25 -o $(OUTFILE) 25 -o $(OUTFILE)
diff --git a/clientmain.go b/clientmain.go
index 91fcae0..a006feb 100644
--- a/clientmain.go
+++ b/clientmain.go
@@ -12,10 +12,10 @@ import (
12 _ "time/tzdata" 12 _ "time/tzdata"
13) 13)
14 14
15var appVersion string 15var version string
16 16
17func main() { 17func main() {
18 cmd := client.NewClientCommand(appVersion) 18 cmd := client.NewClientCommand(version)
19 19
20 if err := cmd.Execute(); err != nil { 20 if err := cmd.Execute(); err != nil {
21 log.Fatalf("Error running root command: %s", err) 21 log.Fatalf("Error running root command: %s", err)
diff --git a/cmd/client/client.go b/cmd/client/client.go
index 1115673..54d7190 100644
--- a/cmd/client/client.go
+++ b/cmd/client/client.go
@@ -28,9 +28,10 @@ var clientId string
28 28
29func NewClientCommand(appVersion string) *cobra.Command { 29func NewClientCommand(appVersion string) *cobra.Command {
30 clientCmd := &cobra.Command{ 30 clientCmd := &cobra.Command{
31 Use: "client proxy-host ssh-to-host ssh-port username", 31 Use: "client proxy-host ssh-to-host ssh-port username",
32 Short: fmt.Sprintf("Run websocket client (version %s)", appVersion), 32 Short: "Run websocket client",
33 Args: cobra.ExactArgs(3), 33 Args: cobra.ExactArgs(3),
34 Version: appVersion,
34 Run: func(c *cobra.Command, args []string) { 35 Run: func(c *cobra.Command, args []string) {
35 cfg := app.Config{} 36 cfg := app.Config{}
36 cli.MustGetConfig(c, &cfg) 37 cli.MustGetConfig(c, &cfg)
diff --git a/main.go b/main.go
index fd2de2c..81863d0 100644
--- a/main.go
+++ b/main.go
@@ -4,7 +4,6 @@ package main
4 4
5import ( 5import (
6 "embed" 6 "embed"
7 "fmt"
8 "log" 7 "log"
9 8
10 "code.crute.us/mcrute/ssh-proxy/app" 9 "code.crute.us/mcrute/ssh-proxy/app"
@@ -32,8 +31,9 @@ var version string
32 31
33func main() { 32func main() {
34 r := &cobra.Command{ 33 r := &cobra.Command{
35 Use: "web-server", 34 Use: "web-server",
36 Short: fmt.Sprintf("SSH proxy web server (version %s)", version), 35 Short: "SSH proxy web server",
36 Version: version,
37 } 37 }
38 cli.AddFlags(r, &app.Config{}, app.DefaultConfig, "") 38 cli.AddFlags(r, &app.Config{}, app.DefaultConfig, "")
39 39