Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/app/skill_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions internal/app/skill_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion internal/helpers/todo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
25 changes: 25 additions & 0 deletions internal/helpers/todo_yes_shorthand_test.go
Original file line number Diff line number Diff line change
@@ -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)")
}
}