fix: alias argument expansion with flags and spaces

Fixes an issue where alias arguments containing spaces or flags were being split incorrectly by using strings.Fields on the substituted command string. Instead, the command string is tokenized first and then substitution happens on each token.

Also disables Cobra flag parsing for aliases dynamically so that arguments and flags correctly cascade down to the target command instead of throwing unknown flag errors.
This commit is contained in:
2026-03-29 19:09:06 +02:00
parent 13b4c4b651
commit 05261522a0
4 changed files with 66 additions and 12 deletions

View File

@@ -33,9 +33,10 @@ func registerAliasCommands() {
for _, a := range aliases {
a := a
rootCmd.AddCommand(&cobra.Command{
Use: a.Name,
Short: a.Description,
GroupID: "aliases",
Use: a.Name,
Short: a.Description,
GroupID: "aliases",
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
expanded := service.ExpandAlias(a, args, cfg.GetUser())
rootCmd.SetArgs(transformArgs(expanded))