PT-1534 Adding support for --version argument

This commit is contained in:
guriandoro
2018-07-04 18:13:07 -04:00
parent 57bb51f467
commit 8e90b31b3b

View File

@@ -67,6 +67,8 @@ type myDefaults struct {
} }
const ( const (
TOOLNAME = "pt-secure-collect"
decryptCmd = "decrypt" decryptCmd = "decrypt"
encryptCmd = "encrypt" encryptCmd = "encrypt"
collectCmd = "collect" collectCmd = "collect"
@@ -81,6 +83,10 @@ var (
"pt-summary", "pt-summary",
"pt-mysql-summary --host=$mysql-host --port=$mysql-port --user=$mysql-user --password=$mysql-pass", "pt-mysql-summary --host=$mysql-host --port=$mysql-port --user=$mysql-user --password=$mysql-pass",
} }
Build string = "01-01-1980"
GoVersion string = "1.8"
Version string = "3.0.1"
) )
func main() { func main() {
@@ -164,12 +170,15 @@ func processCliParams(baseTempPath string, usageWriter io.Writer) (*cliOptions,
} }
msg += "\n " msg += "\n "
app := kingpin.New("pt-secure-collect", msg) app := kingpin.New(TOOLNAME, msg)
if usageWriter != nil { if usageWriter != nil {
app.UsageWriter(usageWriter) app.UsageWriter(usageWriter)
app.Terminate(nil) app.Terminate(nil)
} }
// Add support for --version flag
app.Version(TOOLNAME + "\nVersion " + Version + "\nBuild: " + Build + " using " + GoVersion)
opts := &cliOptions{ opts := &cliOptions{
CollectCommand: app.Command(collectCmd, "Collect, sanitize, pack and encrypt data from pt-tools."), CollectCommand: app.Command(collectCmd, "Collect, sanitize, pack and encrypt data from pt-tools."),
DecryptCommand: app.Command(decryptCmd, "Decrypt an encrypted file. The password will be requested from the terminal."), DecryptCommand: app.Command(decryptCmd, "Decrypt an encrypted file. The password will be requested from the terminal."),