Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Commit 91622d4

Browse files
committed
Add a flag that prints version information
Resolves #51
1 parent eba08e4 commit 91622d4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ci/build.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22
export GOARCH=amd64
33

4+
tag=$(git describe --tags)
5+
46
build(){
57
tmpdir=$(mktemp -d)
6-
go build -o $tmpdir/sshcode
8+
go build -ldflags "-X main.version=${tag}" -o $tmpdir/sshcode
79

810
pushd $tmpdir
911
tarname=sshcode-$GOOS-$GOARCH.tar

main.go

+9
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ func flagHelp() string {
5555
return bd.String()
5656
}
5757

58+
// version is overwritten by ci/build.sh.
59+
var version string
60+
5861
func main() {
5962
var (
6063
skipSyncFlag = flag.Bool("skipsync", false, "skip syncing local settings and extensions to remote host")
6164
sshFlags = flag.String("ssh-flags", "", "custom SSH flags")
6265
syncBack = flag.Bool("b", false, "sync extensions back on termination")
66+
printVersion = flag.Bool("version", false, "print version information and exit")
6367
)
6468

6569
flag.Usage = func() {
@@ -81,6 +85,11 @@ Arguments:
8185
}
8286

8387
flag.Parse()
88+
if *printVersion {
89+
fmt.Printf("%v\n", version)
90+
os.Exit(0)
91+
}
92+
8493
host := flag.Arg(0)
8594

8695
if host == "" {

0 commit comments

Comments
 (0)