Skip to content

Commit

Permalink
add option for extended version (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelAtDeluxe authored Sep 28, 2020
1 parent 007e44e commit 77fbfe6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ run-version:
run-reset-hard:
go run $(LD_FLAGS) cmd/aterm/*.go -reset-hard

.PHONY: run-help
run-help:
go run $(LD_FLAGS) cmd/aterm/*.go -h

.PHONY: debug
debug:
go run $(LD_FLAGS) cmd/aterm/*.go 2>debug.log
Expand Down
8 changes: 7 additions & 1 deletion cmd/aterm/appdialogs/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ import (
// PrintVersion prints a simple sentence that lists the current version and commit hash
// Note: this should only be called _after_ parsing CLI options
func PrintVersion() {
printfln("ATerm Version: %v Build Hash: %v", config.Version(), config.CommitHash())
printline("ATerm Version:", config.Version(), " Build Hash:", config.CommitHash())
}

// PrintExtendedVersion prints more version information: the go runtime and the build date
// Note: this should only be called _after_ parsing CLI options
func PrintExtendedVersion() {
printline("Go runtime:", config.GoRuntime(), " Build Date:", config.BuildDate())
}
3 changes: 2 additions & 1 deletion cmd/aterm/climain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func main() {

appdialogs.PrintVersion()

if info.Flag() {
if info.Flag() || opts.PrintVersion {
appdialogs.PrintExtendedVersion()
return // exit if they ask to print the version
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/aterm/config/cli_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CLIOptions struct {
PrintConfig bool
ForceFirstRun bool
HardReset bool
PrintVersion bool
}

// ParseCLI parses all (supported) arguments from the command line and stores them in a CLIOptions
Expand All @@ -27,7 +28,7 @@ func ParseCLI() CLIOptions {
attachBoolFlag("print-config", "pc", "Print current configuration (post-command line arguments), then exits", false, &opts.PrintConfig)
attachBoolFlag("reset", "", "Rerun first run to set up initial values", false, &opts.ForceFirstRun)
attachBoolFlag("reset-hard", "", "Ignore the config file and rerun first run", false, &opts.HardReset)

attachBoolFlag("v", "", "output the software version and build information", false, &opts.PrintVersion)
flag.Parse()
return opts
}
Expand Down

0 comments on commit 77fbfe6

Please sign in to comment.