Skip to content

Commit

Permalink
misc: add --version flag
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Pashmfouroush <[email protected]>
  • Loading branch information
markpash committed May 2, 2024
1 parent 69b0727 commit 4dc2259
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- name: Build warp-plus
run: |
go build -v -o build_assets/ -trimpath -ldflags "-s -w -buildid=" .
go build -v -o build_assets/ -trimpath -ldflags "-s -w -buildid= -X main.version=${{ github.ref }}" .
- name: Copy README.md & LICENSE
run: |
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/armon/go-proxyproto v0.0.0-20180202201750-5b7edb60ff5f // indirect
github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61 // indirect
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9 // indirect
github.com/cognusion/go-cache-lru v0.0.0-20170419142635-f73e2280ecea // indirect
github.com/dchest/siphash v1.2.3 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/bepass-org/psiphon-tunnel-core v0.0.0-20240311155012-9c2e10df08e5 h1:
github.com/bepass-org/psiphon-tunnel-core v0.0.0-20240311155012-9c2e10df08e5/go.mod h1:vA5iCui7nfavWyBN8MsLYZ5xpKItjrTvPC0SuMWz48Q=
github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61 h1:BU+NxuoaYPIvvp8NNkNlLr8aA0utGyuunf4Q3LJ0bh0=
github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc=
github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9 h1:a1zrFsLFac2xoM6zG1u72DWJwZG3ayttYLfmLbxVETk=
Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/bepass-org/warp-plus/warp"
"github.com/bepass-org/warp-plus/wiresocks"

"github.com/carlmjohnson/versioninfo"
"github.com/peterbourgon/ff/v4"
"github.com/peterbourgon/ff/v4/ffhelp"
"github.com/peterbourgon/ff/v4/ffjson"
Expand Down Expand Up @@ -59,6 +60,8 @@ var psiphonCountries = []string{
"US",
}

var version string = ""

func main() {
fs := ff.NewFlagSet(appName)
var (
Expand All @@ -75,6 +78,7 @@ func main() {
rtt = fs.DurationLong("rtt", 1000*time.Millisecond, "scanner rtt limit")
cacheDir = fs.StringLong("cache-dir", "", "directory to store generated profiles")
_ = fs.String('c', "config", "", "path to config file")
verFlag = fs.BoolLong("version", "displays version number")
)

err := ff.Parse(
Expand All @@ -92,6 +96,14 @@ func main() {
os.Exit(1)
}

if *verFlag {
if version == "" {
version = versioninfo.Short()
}
fmt.Fprintf(os.Stderr, "%s\n", version)
os.Exit(0)
}

l := slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))

if *verbose {
Expand Down

0 comments on commit 4dc2259

Please sign in to comment.