From f5b72f67e5f19d57a6a9ad518bd50d8bef2b0a55 Mon Sep 17 00:00:00 2001 From: Neo Anderson Date: Fri, 4 Apr 2025 19:03:12 -0700 Subject: [PATCH 1/2] Route --version output to stdout --- cmd/saml2aws/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/saml2aws/main.go b/cmd/saml2aws/main.go index c30ccc483..07c9fd75b 100644 --- a/cmd/saml2aws/main.go +++ b/cmd/saml2aws/main.go @@ -2,6 +2,7 @@ package main import ( "crypto/tls" + "fmt" "io" "log" "net/http" @@ -60,7 +61,16 @@ func main() { } app := kingpin.New("saml2aws", "A command line tool to help with SAML access to the AWS token service.") - app.Version(Version) + + versionFlag := app.Flag("version", "Show application version.").Bool() + // Preaction to route --version output to stdout + app.PreAction(func(c *kingpin.ParseContext) error { + if versionFlag != nil && *versionFlag { + fmt.Println(Version) + os.Exit(0) + } + return nil + }) // Settings not related to commands verbose := app.Flag("verbose", "Enable verbose logging").Bool() From 6792f64d2514c19a085080f7c796726090cd95de Mon Sep 17 00:00:00 2001 From: Neo Anderson Date: Fri, 25 Apr 2025 14:56:10 -0700 Subject: [PATCH 2/2] write to os.stdout --- cmd/saml2aws/main.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/cmd/saml2aws/main.go b/cmd/saml2aws/main.go index 07c9fd75b..3247192ba 100644 --- a/cmd/saml2aws/main.go +++ b/cmd/saml2aws/main.go @@ -2,7 +2,6 @@ package main import ( "crypto/tls" - "fmt" "io" "log" "net/http" @@ -60,17 +59,9 @@ func main() { logrus.SetOutput(os.Stdout) } - app := kingpin.New("saml2aws", "A command line tool to help with SAML access to the AWS token service.") - - versionFlag := app.Flag("version", "Show application version.").Bool() - // Preaction to route --version output to stdout - app.PreAction(func(c *kingpin.ParseContext) error { - if versionFlag != nil && *versionFlag { - fmt.Println(Version) - os.Exit(0) - } - return nil - }) + app := kingpin.New("saml2aws", "A command line tool to help with SAML access to the AWS token service."). + Version(Version). + UsageWriter(os.Stdout) // Settings not related to commands verbose := app.Flag("verbose", "Enable verbose logging").Bool()