diff --git a/internal/app/skill_setup.go b/internal/app/skill_setup.go index 4a43f195..193c56e9 100644 --- a/internal/app/skill_setup.go +++ b/internal/app/skill_setup.go @@ -69,7 +69,10 @@ multi 模式支持按产品挑选: cmd.Flags().String("mode", "", "skill 模式:mono | multi(不指定则交互询问)") cmd.Flags().String("target", "all", "目标 Agent:all | "+supportedTargets()) cmd.Flags().String("source", "", "skill 源目录(默认自动查找二进制旁边或当前目录)") - cmd.Flags().Bool("yes", false, "跳过所有确认提示") + // -y shorthand registered locally: the global persistent --yes/-y is + // shadowed by this same-named local flag during cobra's persistent-flag + // merge, so without it `-y` fails with "unknown shorthand flag: 'y'" (#370). + cmd.Flags().BoolP("yes", "y", false, "跳过所有确认提示") cmd.Flags().StringSliceP("skill", "s", nil, "multi 模式:仅安装指定子 skill(可重复,接受短名 aitable 或全名 dingtalk-aitable)") cmd.Flags().StringSliceP("exclude", "x", nil, "multi 模式:从全装中剔除指定子 skill(可重复,与 --skill 互斥)") return cmd diff --git a/internal/app/skill_setup_test.go b/internal/app/skill_setup_test.go index 6d28c9f9..9a4c0fce 100644 --- a/internal/app/skill_setup_test.go +++ b/internal/app/skill_setup_test.go @@ -521,6 +521,25 @@ func TestSkillSetupMultiAdditivePreservesSiblings(t *testing.T) { } } +// TestSkillSetupHasYesShorthand is a regression test for #370: the local --yes +// flag on `skill setup` shadows the global persistent --yes/-y during cobra's +// flag merge, so the -y shorthand must be registered locally too, otherwise +// `dws skill setup -y` fails with "unknown shorthand flag: 'y'". +func TestSkillSetupHasYesShorthand(t *testing.T) { + cmd := newSkillSetupCommand() + + yesFlag := cmd.Flags().Lookup("yes") + if yesFlag == nil { + t.Fatal("skill setup command is missing the --yes flag") + } + if yesFlag.Shorthand != "y" { + t.Errorf("--yes shorthand = %q, want %q (regression #370)", yesFlag.Shorthand, "y") + } + if cmd.Flags().ShorthandLookup("y") == nil { + t.Error("-y shorthand is not resolvable on `skill setup` (regression #370)") + } +} + // TestRunSkillSetupRejectsSkillFlagInMonoMode verifies that the new // -s/--skill and -x/--exclude flags are gated on --mode multi. func TestRunSkillSetupRejectsSkillFlagInMonoMode(t *testing.T) { diff --git a/internal/helpers/todo.go b/internal/helpers/todo.go index 7f2b0bc1..97fc7951 100644 --- a/internal/helpers/todo.go +++ b/internal/helpers/todo.go @@ -466,7 +466,11 @@ func newTodoTaskDeleteCommand(runner executor.Runner) *cobra.Command { preferLegacyLeaf(cmd) cmd.Flags().String("task-id", "", i18n.T("待办任务 ID (必填)")) - cmd.Flags().Bool("yes", false, i18n.T("跳过确认直接删除")) + // Register the -y shorthand locally. The global persistent --yes/-y is + // shadowed by this same-named local flag during cobra's persistent-flag + // merge, so without the shorthand here `-y` reports "unknown shorthand + // flag: 'y'" on this subcommand (#370). + cmd.Flags().BoolP("yes", "y", false, i18n.T("跳过确认直接删除")) return cmd } diff --git a/internal/helpers/todo_yes_shorthand_test.go b/internal/helpers/todo_yes_shorthand_test.go new file mode 100644 index 00000000..4c892cca --- /dev/null +++ b/internal/helpers/todo_yes_shorthand_test.go @@ -0,0 +1,25 @@ +// Copyright 2026 Alibaba Group +// Licensed under the Apache License, Version 2.0 + +package helpers + +import "testing" + +// TestTodoTaskDeleteHasYesShorthand is a regression test for #370: the local +// --yes flag on `todo task delete` shadows the global persistent --yes/-y, so +// the -y shorthand must be registered on the local flag too, otherwise +// `dws todo task delete -y` fails with "unknown shorthand flag: 'y'". +func TestTodoTaskDeleteHasYesShorthand(t *testing.T) { + cmd := newTodoTaskDeleteCommand(nil) + + yesFlag := cmd.Flags().Lookup("yes") + if yesFlag == nil { + t.Fatal("delete command is missing the --yes flag") + } + if yesFlag.Shorthand != "y" { + t.Errorf("--yes shorthand = %q, want %q (regression #370)", yesFlag.Shorthand, "y") + } + if cmd.Flags().ShorthandLookup("y") == nil { + t.Error("-y shorthand is not resolvable on `todo task delete` (regression #370)") + } +}