diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-05 10:26:16 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-05 10:26:16 +0300 |
| commit | 1433f7a13ede0c819ec4f8fd4027ad3df8daa94f (patch) | |
| tree | d3e98bc150711350585dd8203c5b50cc93243e52 /internal/askcli/command_edit.go | |
| parent | 0a52adf5752835da01e8a29df15e415398165c48 (diff) | |
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 <amp@ampcode.com>
Diffstat (limited to 'internal/askcli/command_edit.go')
| -rw-r--r-- | internal/askcli/command_edit.go | 30 |
1 files changed, 30 insertions, 0 deletions
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) +} |
