diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-29 17:39:29 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-29 17:39:29 +0300 |
| commit | 5b49734f3e2bba38e689f274d39e5ff3b52f529d (patch) | |
| tree | f34085421da47a11761412e315fa78ac94cfb154 /internal/askcli/command_add.go | |
| parent | b3cf20116d403e4437a2aaa726bdcf188109cf9f (diff) | |
askcli: keep ask add successful when alias assignment fails
Diffstat (limited to 'internal/askcli/command_add.go')
| -rw-r--r-- | internal/askcli/command_add.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/internal/askcli/command_add.go b/internal/askcli/command_add.go index b94fe89..096046d 100644 --- a/internal/askcli/command_add.go +++ b/internal/askcli/command_add.go @@ -45,10 +45,15 @@ func (d *Dispatcher) handleAdd(ctx context.Context, args []string, stdout, stder _, _ = io.WriteString(stderr, "error: could not parse UUID from task creation output\n") return 1, nil } - aliases, err := ensureTaskAliasesForUUIDs([]string{uuid}) - if err != nil { - fmt.Fprintf(stderr, "error: failed to assign task alias: %v\n", err) - return 1, nil + // The task is already created in Taskwarrior. If alias assignment fails + // (e.g. cache lock timeout, validation error, disk full), surface the + // problem as a warning on stderr but still report success on stdout with + // exit 0 so the user does not retry and create a duplicate task. The + // displayed identifier falls back to the UUID when no alias is available. + aliases, aliasErr := ensureTaskAliasesForUUIDs([]string{uuid}) + if aliasErr != nil { + fmt.Fprintf(stderr, "warning: failed to assign task alias: %v\n", aliasErr) + aliases = nil } _, _ = io.WriteString(stdout, FormatCreatedTask(displayTaskAlias(uuid, aliases))) return 0, nil |
