-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add simple flag to print tool version
- Loading branch information
1 parent
412155c
commit 68339f1
Showing
1 changed file
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ import ( | |
"strings" | ||
) | ||
|
||
const Version = "v1.1.0-dev" | ||
|
||
const ChaCha20Poly1305 = "[email protected]" | ||
const EtmSuffix = "[email protected]" | ||
const CbcSuffix = "-cbc" | ||
|
@@ -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() | ||
|
@@ -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")) | ||
} | ||
|