Skip to content

Commit

Permalink
Route deprectated -version to subcommand (#1854)
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
puerco authored Jun 9, 2022
1 parent f812aa5 commit 68e8d93
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/cosign/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 68e8d93

Please sign in to comment.