From 1a6323c0e6c865694266cfab24bc022a5eecb534 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 20 Jun 2026 10:55:58 +0300 Subject: taskwarrior: DRY up export/import into symmetric label helpers The export path passed a file_label argument that was always identical to the tag (TASK_EXPORT_TAG/TASK_EXPORT_TAG, rocky/rocky), and the import path duplicated the find | while read | import/rm block once per source. Collapse both into a single 'list of labels' model: - _taskwarrior::export_tag drops the redundant file_label; the tag name is the file label. - New _taskwarrior::import_label imports+removes all files for one label, replacing the two copy-pasted blocks. - export loops over [$TASK_EXPORT_TAG rocky]; import loops over [$TASK_IMPORT_TAG (hostname)]. The rocky routing (export by tag name, import by hostname match) is now explicit and symmetric. Behaviour is unchanged; verified with a stubbed-task/hostname harness covering the rocky host, a non-rocky host, and label isolation. Co-Authored-By: Claude Opus 4.8 --- fish/conf.d/taskwarrior.fish | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/fish/conf.d/taskwarrior.fish b/fish/conf.d/taskwarrior.fish index 1948629..d3ff34f 100644 --- a/fish/conf.d/taskwarrior.fish +++ b/fish/conf.d/taskwarrior.fish @@ -113,13 +113,13 @@ function taskwarrior::export::wins end # Exports all tasks tagged +$tag for both pending and completed status into -# per-status .json files named after $file_label, then deletes the exported -# tasks. $file_label drives the filename so the matching importer (which keys -# off either TASK_IMPORT_TAG or the hostname) can pick the files up later. +# per-status .json files in $WORKTIME_DIR, then deletes the exported tasks. The +# tag name doubles as the file label (tw--export--.json) so the +# importer can match the files again by tag name or, for host-routed tags like +# "rocky", by hostname. See _taskwarrior::import_label for the matching side. function _taskwarrior::export_tag set -l tag $argv[1] - set -l file_label $argv[2] - set -l ts $argv[3] + set -l ts $argv[2] for task_status in pending completed set -l count (task +$tag status:$task_status count) @@ -128,23 +128,34 @@ function _taskwarrior::export_tag continue end - echo "Exporting $count $task_status tasks to $file_label" - task +$tag status:$task_status export >"$WORKTIME_DIR/tw-$file_label-export-$ts-$task_status.json" + echo "Exporting $count $task_status tasks tagged +$tag" + task +$tag status:$task_status export >"$WORKTIME_DIR/tw-$tag-export-$ts-$task_status.json" yes | task +$tag status:$task_status delete &>/dev/null end end +# Imports and removes every export file in $WORKTIME_DIR whose embedded label +# (the