refactor(corecmd): rename package and finish ContractFinal leaf migration
Move cmdcore to corecmd, declare attendance ContractFinal in helpers, keep Sheet destructive commands --yes-only, and align catalog/policy provenance. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
18e32ad09d
commit
7773eb27f1
237 files changed
+105994
-108400
No files matched your search
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -23,10 +24,17 @@ func executeTodoEdge(t *testing.T, caller *scriptedToolCaller, args ...string) e
|
||||
}()
|
||||
|
||||
cmd := newTodoCommand()
|
||||
if cmd.PersistentFlags().Lookup("yes") == nil {
|
||||
cmd.PersistentFlags().Bool("yes", false, "confirm execution")
|
||||
}
|
||||
if cmd.PersistentFlags().Lookup("dry-run") == nil {
|
||||
cmd.PersistentFlags().Bool("dry-run", false, "preview without executing")
|
||||
}
|
||||
cmd.SilenceErrors = true
|
||||
cmd.SilenceUsage = true
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetErr(io.Discard)
|
||||
cmd.SetIn(os.Stdin)
|
||||
cmd.SetArgs(args)
|
||||
return cmd.Execute()
|
||||
}
|
||||
@@ -215,32 +223,42 @@ func TestCrossPlatformCoverageTodoDeleteCancellationAndConfirmationEdges(t *test
|
||||
os.Stdin = originalStdin
|
||||
}()
|
||||
|
||||
readEnd, writeEnd, err := os.Pipe()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := writeEnd.WriteString("no\nno\nno\n"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = writeEnd.Close()
|
||||
os.Stdin = readEnd
|
||||
os.Args = []string{"dws"}
|
||||
for _, args := range [][]string{
|
||||
{"task", "delete", "--task-id", "1"},
|
||||
// remove-attachment is schema-excluded and still uses confirmDelete (nil cancel).
|
||||
{"task", "remove-attachment", "--task-id", "1", "--attachment-id", "2"},
|
||||
{"comment", "delete", "--task-id", "1", "--comment-id", "2"},
|
||||
} {
|
||||
if err := executeTodoEdge(t, &scriptedToolCaller{}, args...); err != nil {
|
||||
t.Fatalf("cancel %v: %v", args, err)
|
||||
readEnd, writeEnd, err := os.Pipe()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := writeEnd.WriteString("no\n"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = writeEnd.Close()
|
||||
os.Stdin = readEnd
|
||||
err = executeTodoEdge(t, &scriptedToolCaller{}, args...)
|
||||
_ = readEnd.Close()
|
||||
switch args[1] {
|
||||
case "remove-attachment":
|
||||
if err != nil {
|
||||
t.Fatalf("cancel %v: %v", args, err)
|
||||
}
|
||||
default:
|
||||
// Contract ConfirmSafety returns a typed cancel error (not silent nil).
|
||||
if err == nil || !strings.Contains(err.Error(), "用户取消了操作") {
|
||||
t.Fatalf("cancel %v: error = %v, want 用户取消了操作", args, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = readEnd.Close()
|
||||
|
||||
os.Args = []string{"dws", "--yes"}
|
||||
for _, args := range [][]string{
|
||||
{"task", "delete", "--task-id", "1"},
|
||||
{"task", "remove-attachment", "--task-id", "1", "--attachment-id", "2"},
|
||||
{"comment", "delete", "--task-id", "1", "--comment-id", "2"},
|
||||
{"task", "delete", "--task-id", "1", "--yes"},
|
||||
{"task", "remove-attachment", "--task-id", "1", "--attachment-id", "2", "--yes"},
|
||||
{"comment", "delete", "--task-id", "1", "--comment-id", "2", "--yes"},
|
||||
} {
|
||||
if err := executeTodoEdge(t, &scriptedToolCaller{}, args...); err != nil {
|
||||
t.Fatalf("confirm %v: %v", args, err)
|
||||
|
||||
Reference in new issue
Block a user