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

Commit

Permalink
Add a flag that prints version information
Browse files Browse the repository at this point in the history
Resolves #51
  • Loading branch information
ammario committed Apr 23, 2019
1 parent eba08e4 commit 91622d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash
export GOARCH=amd64

tag=$(git describe --tags)

build(){
tmpdir=$(mktemp -d)
go build -o $tmpdir/sshcode
go build -ldflags "-X main.version=${tag}" -o $tmpdir/sshcode

pushd $tmpdir
tarname=sshcode-$GOOS-$GOARCH.tar
Expand Down
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ func flagHelp() string {
return bd.String()
}

// version is overwritten by ci/build.sh.
var version string

func main() {
var (
skipSyncFlag = flag.Bool("skipsync", false, "skip syncing local settings and extensions to remote host")
sshFlags = flag.String("ssh-flags", "", "custom SSH flags")
syncBack = flag.Bool("b", false, "sync extensions back on termination")
printVersion = flag.Bool("version", false, "print version information and exit")
)

flag.Usage = func() {
Expand All @@ -81,6 +85,11 @@ Arguments:
}

flag.Parse()
if *printVersion {
fmt.Printf("%v\n", version)
os.Exit(0)
}

host := flag.Arg(0)

if host == "" {
Expand Down

0 comments on commit 91622d4

Please sign in to comment.