Skip to content

Commit

Permalink
Add cli options to print version
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Jul 16, 2020
1 parent 503eb93 commit 72e0225
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.DEFAULT_GOAL:=local_or_with_proxy

USE_PROXY=GOPROXY=https://goproxy.io
BUILD=go build -ldflags "-s -w"
VERSION:=$(shell git describe --abbrev=7 --dirty --always --tags)
BUILD=go build -ldflags "-s -w -X main.Version=$(VERSION)"
BUILD_DIR=build
BIN_DIR=$(GOOS)-$(GOARCH)
BIN_NAME=nkn-tunnel
Expand Down
11 changes: 11 additions & 0 deletions bin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/hex"
"flag"
"fmt"
"log"
"strings"

Expand All @@ -12,6 +13,10 @@ import (
"github.com/nknorg/tuna"
)

var (
Version string
)

func main() {
numClients := flag.Int("n", 4, "number of clients")
seedHex := flag.String("s", "", "secret seed")
Expand All @@ -23,9 +28,15 @@ func main() {
tunaMaxPrice := flag.String("tuna-max-price", "0.01", "tuna max price in unit of NKN/MB")
mtu := flag.Int("mtu", 0, "ncp session mtu")
verbose := flag.Bool("v", false, "show logs on dialing/accepting connection")
version := flag.Bool("version", false, "print version")

flag.Parse()

if *version {
fmt.Println(Version)
return
}

if len(*from) == 0 {
log.Fatal("From address is empty")
}
Expand Down

0 comments on commit 72e0225

Please sign in to comment.