-
-
Notifications
You must be signed in to change notification settings - Fork 108
pkg/util/embed/flag.go: Support short flags with more than one character #3288
Copy link
Copy link
Labels
enhancementNew feature or requestNew feature or requestfundFundable with polar.shFundable with polar.sh
Description
Request
Currently, embedding short flags that contain more than one character results in an error.
error: unknown shorthand flag: 'c' in -certreq
error: no candidates
~> keytool -certreq -
Short flags with more than one character (e.g., -certreq) should be parsed as a whole instead of being truncated to the first two characters.
Proposed solution
diff --git a/pkg/util/embed/flag.go b/pkg/util/embed/flag.go
index c0f8e18f..f7ca839a 100644
--- a/pkg/util/embed/flag.go
+++ b/pkg/util/embed/flag.go
@@ -31,7 +31,7 @@ func subcommandsAsFlags(cmd *cobra.Command, shorthandOnly bool, subcommands ...*
case strings.HasPrefix(args[0], "--"):
flags.Parse(args[:1])
case strings.HasPrefix(args[0], "-") && len(args[0]) > 1:
- flags.Parse([]string{args[0][:2]})
+ flags.Parse([]string{args[0]})
}
var subcommand *cobra.Command
This works, but I am not sure if it breaks anything else.
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfundFundable with polar.shFundable with polar.sh