Skip to content

Commit

Permalink
feat: Add simple flag to print tool version
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueSkrillor committed Dec 20, 2023
1 parent 412155c commit 68339f1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"strings"
)

const Version = "v1.1.0-dev"

const ChaCha20Poly1305 = "[email protected]"
const EtmSuffix = "[email protected]"
const CbcSuffix = "-cbc"
Expand Down Expand Up @@ -322,6 +324,11 @@ func printReport(report *TerrapinVulnerabilityReport, outputJson bool) error {
return nil
}

// Prints the version of this tool to stdout
func printVersion() {
fmt.Println("Terrapin Vulnerability Scanner " + Version)
}

// Prints a short disclaimer to stdout
func printDisclaimer() {
fmt.Println()
Expand Down Expand Up @@ -351,17 +358,26 @@ func main() {
"no-color",
false,
"Disables colored output.")
versionPtr := flag.Bool(
"version",
false,
"Prints the version of this tool.")
helpPtr := flag.Bool(
"help",
false,
"Prints this usage help to the user.")
flag.Parse()
color.NoColor = *noColor
if (*connectPtr == "" && *listenPtr == "") || *helpPtr {
if (*connectPtr == "" && *listenPtr == "" && !*versionPtr) || *helpPtr {
printVersion()
flag.Usage()
printDisclaimer()
os.Exit(0)
}
if *versionPtr {
printVersion()
os.Exit(0)
}
if *connectPtr != "" && *listenPtr != "" {
panic(fmt.Errorf("unable to determine scan mode. make sure to provide either -connect or -listen"))
}
Expand Down

0 comments on commit 68339f1

Please sign in to comment.