diff options
Diffstat (limited to 'internal/askcli')
| -rw-r--r-- | internal/askcli/command_delete.go | 4 | ||||
| -rw-r--r-- | internal/askcli/command_delete_test.go | 4 | ||||
| -rw-r--r-- | internal/askcli/command_dep.go | 2 | ||||
| -rw-r--r-- | internal/askcli/command_dep_test.go | 4 | ||||
| -rw-r--r-- | internal/askcli/command_list.go | 4 | ||||
| -rw-r--r-- | internal/askcli/command_write.go | 6 | ||||
| -rw-r--r-- | internal/askcli/command_write_test.go | 6 | ||||
| -rw-r--r-- | internal/askcli/dispatch.go | 7 | ||||
| -rw-r--r-- | internal/askcli/dispatch_test.go | 7 | ||||
| -rw-r--r-- | internal/askcli/formatter.go | 4 |
10 files changed, 19 insertions, 29 deletions
diff --git a/internal/askcli/command_delete.go b/internal/askcli/command_delete.go index 1da0498..84764dd 100644 --- a/internal/askcli/command_delete.go +++ b/internal/askcli/command_delete.go @@ -6,7 +6,7 @@ import ( "io" ) -func (d Dispatcher) handleDelete(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) { +func (d Dispatcher) handleDelete(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { if len(args) < 2 { io.WriteString(stderr, "error: ask delete requires a UUID argument\n") return 1, nil @@ -17,7 +17,7 @@ func (d Dispatcher) handleDelete(ctx context.Context, args []string, stdout, std return 1, nil } var outBuf bytes.Buffer - code, err := d.runner.Run(ctx, []string{"delete", uuid}, nil, &outBuf, io.Discard) + code, err := d.runner.Run(ctx, []string{"uuid:" + uuid, "delete"}, stdin, &outBuf, io.Discard) if code != 0 { return code, err } diff --git a/internal/askcli/command_delete_test.go b/internal/askcli/command_delete_test.go index e07205f..9cd2e94 100644 --- a/internal/askcli/command_delete_test.go +++ b/internal/askcli/command_delete_test.go @@ -86,7 +86,7 @@ func TestHandleDelete_PassesCorrectArgs(t *testing.T) { }}) var stdout, stderr bytes.Buffer d.Dispatch(context.Background(), []string{"delete", "my-uuid"}, &bytes.Buffer{}, &stdout, &stderr) - if len(capturedArgs) != 2 || capturedArgs[0] != "delete" || capturedArgs[1] != "my-uuid" { - t.Fatalf("capturedArgs = %v, want [delete, my-uuid]", capturedArgs) + if len(capturedArgs) != 2 || capturedArgs[0] != "uuid:my-uuid" || capturedArgs[1] != "delete" { + t.Fatalf("capturedArgs = %v, want [uuid:my-uuid, delete]", capturedArgs) } } diff --git a/internal/askcli/command_dep.go b/internal/askcli/command_dep.go index a7df0cb..035186e 100644 --- a/internal/askcli/command_dep.go +++ b/internal/askcli/command_dep.go @@ -67,7 +67,7 @@ func (d Dispatcher) handleDepList(ctx context.Context, args []string, stdout, st return 1, nil } var outBuf bytes.Buffer - code, err := d.runner.Run(ctx, []string{"info", uuid}, nil, &outBuf, stderr) + code, err := d.runner.Run(ctx, []string{"uuid", uuid, "export"}, nil, &outBuf, stderr) if code != 0 { return code, err } diff --git a/internal/askcli/command_dep_test.go b/internal/askcli/command_dep_test.go index c77bc1a..26ddf08 100644 --- a/internal/askcli/command_dep_test.go +++ b/internal/askcli/command_dep_test.go @@ -36,9 +36,7 @@ func TestHandleDep_RmSuccess(t *testing.T) { func TestHandleDep_ListSuccess(t *testing.T) { jsonData := `[{"uuid":"uuid-1","description":"Task","status":"pending","priority":"M","tags":[],"urgency":10,"depends":["dep-1","dep-2"]}]` d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { - if args[0] == "info" { - io.WriteString(stdout, jsonData) - } + io.WriteString(stdout, jsonData) return 0, nil }}) var stdout, stderr bytes.Buffer diff --git a/internal/askcli/command_list.go b/internal/askcli/command_list.go index 1ba9352..b5c5429 100644 --- a/internal/askcli/command_list.go +++ b/internal/askcli/command_list.go @@ -38,7 +38,7 @@ func (d Dispatcher) handleList(ctx context.Context, args []string, stdout, stder } func (d Dispatcher) handleAll(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) { - filterArgs := []string{"export", "status:any"} + filterArgs := []string{"export"} for _, arg := range args[1:] { if strings.HasPrefix(arg, "limit:") || strings.HasPrefix(arg, "sort:") || strings.HasPrefix(arg, "+") || arg == "started" { @@ -67,7 +67,7 @@ func (d Dispatcher) handleAll(ctx context.Context, args []string, stdout, stderr } func (d Dispatcher) handleReady(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) { - filterArgs := []string{"export", "+READY"} + filterArgs := []string{"+READY", "export"} for _, arg := range args[1:] { if strings.HasPrefix(arg, "limit:") || strings.HasPrefix(arg, "sort:") || strings.HasPrefix(arg, "+") || arg == "started" { diff --git a/internal/askcli/command_write.go b/internal/askcli/command_write.go index b39b64a..c55bd95 100644 --- a/internal/askcli/command_write.go +++ b/internal/askcli/command_write.go @@ -19,7 +19,7 @@ func (d Dispatcher) handleDenotate(ctx context.Context, args []string, stdout, s } text := args[2] var outBuf bytes.Buffer - code, err := d.runner.Run(ctx, []string{"denotate", uuid, text}, nil, &outBuf, io.Discard) + code, err := d.runner.Run(ctx, []string{"uuid:" + uuid, "denotate", text}, nil, &outBuf, io.Discard) if code != 0 { return code, err } @@ -136,7 +136,7 @@ func (d Dispatcher) handlePriority(ctx context.Context, args []string, stdout, s } priority := args[2] var outBuf bytes.Buffer - code, err := d.runner.Run(ctx, []string{"priority", uuid, priority}, nil, &outBuf, io.Discard) + code, err := d.runner.Run(ctx, []string{"uuid:" + uuid, "modify", "priority:" + priority}, nil, &outBuf, io.Discard) if code != 0 { return code, err } @@ -156,7 +156,7 @@ func (d Dispatcher) handleTag(ctx context.Context, args []string, stdout, stderr } tag := args[2] var outBuf bytes.Buffer - code, err := d.runner.Run(ctx, []string{"tag", uuid, tag}, nil, &outBuf, io.Discard) + code, err := d.runner.Run(ctx, []string{"uuid:" + uuid, "modify", tag}, nil, &outBuf, io.Discard) if code != 0 { return code, err } diff --git a/internal/askcli/command_write_test.go b/internal/askcli/command_write_test.go index 3b9d937..f0e062d 100644 --- a/internal/askcli/command_write_test.go +++ b/internal/askcli/command_write_test.go @@ -201,14 +201,14 @@ func TestAllWriteHandlers_PassCorrectArgs(t *testing.T) { args []string wantArgs []string }{ - {"denotate", []string{"denotate", "my-uuid", "text"}, []string{"denotate", "my-uuid", "text"}}, + {"denotate", []string{"denotate", "my-uuid", "text"}, []string{"uuid:my-uuid", "denotate", "text"}}, {"modify", []string{"modify", "my-uuid", "priority:H"}, []string{"modify", "my-uuid", "priority:H"}}, {"annotate", []string{"annotate", "my-uuid", "note"}, []string{"annotate", "my-uuid", "note"}}, {"start", []string{"start", "my-uuid"}, []string{"start", "my-uuid"}}, {"stop", []string{"stop", "my-uuid"}, []string{"stop", "my-uuid"}}, {"done", []string{"done", "my-uuid"}, []string{"done", "my-uuid"}}, - {"priority", []string{"priority", "my-uuid", "H"}, []string{"priority", "my-uuid", "H"}}, - {"tag", []string{"tag", "my-uuid", "+cli"}, []string{"tag", "my-uuid", "+cli"}}, + {"priority", []string{"priority", "my-uuid", "H"}, []string{"uuid:my-uuid", "modify", "priority:H"}}, + {"tag", []string{"tag", "my-uuid", "+cli"}, []string{"uuid:my-uuid", "modify", "+cli"}}, } for _, tc := range testCases { diff --git a/internal/askcli/dispatch.go b/internal/askcli/dispatch.go index 42097c5..312a6cf 100644 --- a/internal/askcli/dispatch.go +++ b/internal/askcli/dispatch.go @@ -28,8 +28,6 @@ func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader } subcommand := args[0] switch subcommand { - case "export": - return d.runner.Run(ctx, args, stdin, stdout, stderr) case "info": return d.handleInfo(ctx, args, stdout, stderr) case "add": @@ -61,7 +59,7 @@ func (d Dispatcher) Dispatch(ctx context.Context, args []string, stdin io.Reader case "denotate": return d.handleDenotate(ctx, args, stdout, stderr) case "delete": - return d.handleDelete(ctx, args, stdout, stderr) + return d.handleDelete(ctx, args, stdin, stdout, stderr) case "help": return d.help(stdout) default: @@ -90,9 +88,6 @@ func (d Dispatcher) help(w io.Writer) (int, error) { io.WriteString(w, " ask modify <uuid> <args...> Modify task fields\n") io.WriteString(w, " ask denotate <uuid> \"text\" Remove annotation\n") io.WriteString(w, " ask delete <uuid> Delete task\n") - io.WriteString(w, " ask export Raw JSON export\n") - io.WriteString(w, "\nFilters:\n") - io.WriteString(w, " +READY +BLOCKED +<tag> started limit:N sort:priority-,urgency-\n") return 0, nil } diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go index 005a88c..1586447 100644 --- a/internal/askcli/dispatch_test.go +++ b/internal/askcli/dispatch_test.go @@ -28,9 +28,6 @@ func TestDispatcher_Help(t *testing.T) { if !strings.Contains(output, "ask all") { t.Fatalf("help missing all subcommand: %s", output) } - if !strings.Contains(output, "Filters:") { - t.Fatalf("help missing Filters section: %s", output) - } } func TestDispatcher_UnknownSubcommand(t *testing.T) { @@ -54,7 +51,7 @@ func TestDispatcher_LongHelp(t *testing.T) { var stdout bytes.Buffer d.Dispatch(context.Background(), []string{"help"}, nil, &stdout, io.Discard) output := stdout.String() - for _, sub := range []string{"add", "list", "all", "ready", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete", "export"} { + for _, sub := range []string{"add", "list", "all", "ready", "info", "annotate", "start", "stop", "done", "priority", "tag", "dep", "urgency", "modify", "denotate", "delete"} { if !strings.Contains(output, "ask "+sub) { t.Errorf("help missing subcommand: ask %s", sub) } @@ -62,7 +59,7 @@ func TestDispatcher_LongHelp(t *testing.T) { } func TestDispatcher_AllSubcommandsReachExecutor(t *testing.T) { - subcommands := []string{"export"} + subcommands := []string{} subcommandArgs := map[string][]string{ "delete": {"delete", "test-uuid"}, "denotate": {"denotate", "test-uuid", "text"}, diff --git a/internal/askcli/formatter.go b/internal/askcli/formatter.go index e210dc7..41e3b3b 100644 --- a/internal/askcli/formatter.go +++ b/internal/askcli/formatter.go @@ -8,7 +8,7 @@ import ( func FormatTaskList(tasks []TaskExport) string { var b strings.Builder - io.WriteString(&b, "UUID | Priority | Status | Tags | Description | Urgency\n") + io.WriteString(&b, "Urgency | Priority | UUID | Status | Tags | Description\n") io.WriteString(&b, strings.Repeat("-", 120)+"\n") for _, t := range tasks { tags := strings.Join(t.Tags, ",") @@ -19,7 +19,7 @@ func FormatTaskList(tasks []TaskExport) string { if len(desc) > 50 { desc = desc[:47] + "..." } - fmt.Fprintf(&b, "%s | %s | %s | %s | %s | %.1f\n", t.UUID, t.Priority, t.Status, tags, desc, t.Urgency) + fmt.Fprintf(&b, "%.1f | %s | %s | %s | %s | %s\n", t.Urgency, t.Priority, t.UUID, t.Status, tags, desc) } return b.String() } |
