Skip to content

feat(move): tsk move <id> --to <path> for cross-file migration#9

Merged
Sanjays2402 merged 2 commits into
mainfrom
feat/move
May 17, 2026
Merged

feat(move): tsk move <id> --to <path> for cross-file migration#9
Sanjays2402 merged 2 commits into
mainfrom
feat/move

Conversation

@Sanjays2402

Copy link
Copy Markdown
Owner

What

Add tsk move <id...> --to <path> for migrating tasks between .tsk.md files.

I use multiple .tsk.md files (one per project), and there was no way to move tasks between them without copy-pasting markdown. This fixes that.

Flags

Flag Behavior
--to <path> destination .tsk.md (required)
--dry-run preview which tasks would move; no writes
--keep-ids preserve source IDs in destination, error on collision

By default IDs are reassigned in the destination (using its nextID()), so they slot in naturally next to existing tasks. --keep-ids is for migrations where you want to keep history-stable IDs and you've verified no collisions.

Atomicity

The implementation saves the destination first, then removes from source. If the destination save fails, the source is untouched. The worst case is a duplicate (both files contain the task), which is detectable via the new tsk doctor command (PR #8).

Example

$ tsk move 3 7 --to ~/work.tsk.md
moved 2 tasks to /Users/sanjay/work.tsk.md (ids: 5, 6)

$ tsk move 1 --to ~/work.tsk.md --dry-run
DRY RUN — would move 1 task:
  1  refactor parser     →  ~/work.tsk.md (new id: 7)

Tests

9 new tests in internal/commands/move_test.go:

  • basic single move
  • multi-ID move
  • --dry-run preserves source and skips destination write
  • missing --to flag rejected
  • self-move (same canonical path) rejected
  • bogus ID rejected
  • destination file created when absent
  • IDs reassigned by default
  • --keep-ids collision detected

…tion

Moves one or more tasks between `.tsk.md` files. Useful when a task
belongs in a different project, or when archiving completed work
to a separate file.

Flags
  --to <path>     destination .tsk.md (required)
  --dry-run       preview move without touching disk
  --keep-ids      preserve source IDs in destination (errors on collision)

By default, IDs are reassigned in the destination via its nextID().
With --keep-ids, a collision (same id already present in destination)
fails fast before either file is modified.

Atomicity
  Destination is saved first, source is purged second. If destination
  save fails, source is untouched. Worst case is duplication (both files
  contain the task), which is detectable via `tsk doctor`.

Refuses to move when --to resolves to the same canonical path as the
source store ("same file" error).
@Sanjays2402 Sanjays2402 merged commit d19a11c into main May 17, 2026
4 checks passed
@Sanjays2402 Sanjays2402 deleted the feat/move branch May 17, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant