Skip to content

Commit

Permalink
Fix version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
triole committed Oct 18, 2024
1 parent d63a715 commit 377d9a8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/argparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ var CLI struct {
LogNoColors bool `help:"disable output colours, print plain text"`
LogJSON bool `help:"enable json log, instead of text one"`
DryRun bool `help:"dry run, just print don't do" short:"n"`
VersionFlag bool `help:"display version" short:"V"`

List struct {
Plain bool `help:"print plain list, file names only" short:"p"`
Expand Down Expand Up @@ -65,6 +64,8 @@ var CLI struct {
Remove struct {
Yes bool `help:"assume yes on remove affirmation query"`
} `cmd:"" help:"remove matching files"`

Version struct{} `cmd:"" help:"display version"`
}

func parseArgs() {
Expand All @@ -84,14 +85,14 @@ func parseArgs() {
"compressionFormats": "brotli,bz2,gz,lz4,snappy,xz",
},
)
CLI.SubCommand = ctx.Command()
_ = ctx.Run()

if CLI.VersionFlag {
if ctx.Command() == "version" {
printBuildTags(BUILDTAGS)
os.Exit(0)
}
// ctx.FatalIfErrorf(err)

CLI.SubCommand = ctx.Command()
}

type tPrinter []tPrinterEl
Expand Down

0 comments on commit 377d9a8

Please sign in to comment.