Skip to content

fix(cli): restore -y shorthand on todo task delete and skill setup#417

Open
jackjin1997 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
jackjin1997:fix/yes-shorthand-shadow-370
Open

fix(cli): restore -y shorthand on todo task delete and skill setup#417
jackjin1997 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
jackjin1997:fix/yes-shorthand-shadow-370

Conversation

@jackjin1997
Copy link
Copy Markdown

Summary

  • What changed? Registered the -y shorthand on the local --yes flags of dws todo task delete (internal/helpers/todo.go) and dws skill setup (internal/app/skill_setup.go) — Bool("yes")BoolP("yes", "y", ...).
  • Why? Both subcommands declare a local --yes flag with the same name as the global persistent --yes/-y. During cobra's persistent-flag merge, the same-named parent flag (and its -y shorthand) is skipped, so -y resolved to nothing:
    $ dws todo task delete --task-id <id> -y
    { "error": { "message": "unknown shorthand flag: 'y' in -y" } }
    
    Only the long --yes worked, which is surprising for an AI-agent-oriented CLI where -y is the documented global shorthand.

Fixes #370

Verification

  • make build
  • make lintgo vet passes; staticcheck not installed in my local env (CI covers it)
  • go test ./internal/helpers/ ./internal/app/ (incl. new TestTodoTaskDeleteHasYesShorthand, TestSkillSetupHasYesShorthand)
  • make policy
  • ./scripts/policy/check-generated-drift.sh
  • ./scripts/policy/check-command-surface.sh --strict

Notes

  • Why add the shorthand instead of removing the local flags (the other option in the issue): removing them would also drop the shorthand and would break a standalone unit test (TestRunSkillSetupRejectsSkillFlagInMonoMode) that constructs skill setup without the root persistent flags and passes --yes. Adding -y is the smaller, safer change that directly fixes the reported symptom and keeps both standalone and mounted usage working — cobra's merge skips the duplicate-named persistent flag, so the local -y becomes the active shorthand with no collision.
  • RunE reads via cmd.Flags().GetBool("yes") in both commands, so behavior is unchanged beyond the shorthand now resolving.

Both subcommands register a local --yes flag with the same name as the global
persistent --yes/-y. During cobra's persistent-flag merge the same-named
parent flag (and its -y shorthand) is skipped, so -y resolved to nothing and
`dws todo task delete -y` / `dws skill setup -y` failed with
"unknown shorthand flag: 'y'" — only the long --yes worked.

Register the -y shorthand on the local flags (Bool -> BoolP). Removing the
local flags instead would drop the shorthand too and also break a standalone
unit test that constructs skill setup without the root persistent flags.

Fixes DingTalk-Real-AI#370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: dws todo task delete / dws skill setup 的 -y 短选项被本地 --yes 屏蔽

1 participant