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

Add a flag that prints version information #56

Merged
merged 1 commit into from
Apr 23, 2019
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
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