From 1433f7a13ede0c819ec4f8fd4027ad3df8daa94f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 5 Jun 2026 10:26:16 +0300 Subject: Add 'ask edit' subcommand and collapse multi-line task descriptions - ask edit opens $EDITOR and creates a task from the (multi-line) content, reusing the shared internal/editor package - collapse newlines in list output and fish completion so multi-line descriptions render on one line and don't break completion Bump version to 0.40.0 Amp-Thread-ID: https://ampcode.com/threads/T-019e96a1-9c8e-73d6-95b4-b55cb12cc762 Co-authored-by: Amp --- internal/askcli/command_edit.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 internal/askcli/command_edit.go (limited to 'internal/askcli/command_edit.go') diff --git a/internal/askcli/command_edit.go b/internal/askcli/command_edit.go new file mode 100644 index 0000000..585f550 --- /dev/null +++ b/internal/askcli/command_edit.go @@ -0,0 +1,30 @@ +package askcli + +import ( + "context" + "io" + + "codeberg.org/snonux/hexai/internal/editor" +) + +// captureFromEditor opens the user's editor on a temporary file and returns its +// trimmed contents after the editor exits. It is a variable so tests can stub it. +var captureFromEditor = func() (string, error) { + return editor.OpenTempAndEdit(nil) +} + +// handleEdit opens the configured editor on a temporary file and creates a new +// task from the resulting (possibly multi-line) content. +func (d *Dispatcher) handleEdit(ctx context.Context, args []string, stdout, stderr io.Writer) (int, error) { + _ = args + description, err := captureFromEditor() + if err != nil { + writeInfoError(stderr, err) + return 1, nil + } + if description == "" { + _, _ = io.WriteString(stderr, "error: ask edit aborted: empty description\n") + return 1, nil + } + return d.createTask(ctx, nil, description, nil, stdout, stderr) +} -- cgit v1.2.3