From 68e8d9375a246a5fbc3607f8a919551164fa8cbf Mon Sep 17 00:00:00 2001 From: Puerco Date: Thu, 9 Jun 2022 16:40:28 -0500 Subject: [PATCH] Route deprectated -version to subcommand (#1854) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the routing of the deprected -version flag to avoid translating it to --version. Instead it routes is to the `version` subcommand. Signed-off-by: Adolfo GarcĂ­a Veytia (Puerco) --- cmd/cosign/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/cosign/main.go b/cmd/cosign/main.go index 00bb0b81ede..2640bc53c15 100644 --- a/cmd/cosign/main.go +++ b/cmd/cosign/main.go @@ -43,7 +43,17 @@ func main() { } else if strings.HasPrefix(arg, "-") { // Handle -output, convert to --output newArg := fmt.Sprintf("-%s", arg) - fmt.Fprintf(os.Stderr, "WARNING: the flag %s is deprecated and will be removed in a future release. Please use the flag %s.\n", arg, newArg) + newArgType := "flag" + if newArg == "--version" { + newArg = "version" + newArgType = "subcommand" + } + fmt.Fprintf( + os.Stderr, + "WARNING: the %s flag is deprecated and will be removed in a future release. "+ + "Please use the %s %s instead.\n", + arg, newArg, newArgType, + ) os.Args[i] = newArg } }