Skip to content

feat(cli+sdk): consolidate default paths under ~/.config/loseit#72

Merged
phitoduck merged 1 commit into
mainfrom
consolidate-default-paths
Jun 13, 2026
Merged

feat(cli+sdk): consolidate default paths under ~/.config/loseit#72
phitoduck merged 1 commit into
mainfrom
consolidate-default-paths

Conversation

@phitoduck

Copy link
Copy Markdown
Owner

Summary

Move backup root + trash file under ~/.config/loseit/ so they sit next to config.yaml and the auth token. Previously they followed XDG strictly (backup + trash in ~/.local/share/loseit/, config in ~/.config/loseit/), which split ~3 files across two top-level directories for no real benefit on a single-user workstation.

New defaults

~/.config/loseit/
  config.yaml
  token
  backup/                  ← was ~/.local/share/loseit/backup/
  trash.jsonl              ← was ~/.local/share/loseit/trash.jsonl

Override mechanisms (in addition to existing CLI flags)

Surface Env var CLI flag
Backup root LOSEIT_BACKUP_ROOT --root
Trash file LOSEIT_TRASH_FILE --trash-file

Typer's envvar= mechanism makes --help self-documenting:

--trash-file  PATH  Source trash file. Default:
                    ~/.config/loseit/trash.jsonl (override
                    via $LOSEIT_TRASH_FILE).
                    [env var: LOSEIT_TRASH_FILE]

Verification

Smoke-tested all four paths:

$ loseit backup --start 2025-12-01 --end 2025-12-31 --dry-run | grep root
  root:               /Users/ericriddoch/.config/loseit/backup     ← new default

$ LOSEIT_BACKUP_ROOT=/tmp/loseit-envvar-test loseit backup ... --dry-run | grep root
  root:               /tmp/loseit-envvar-test                       ← env var wins

$ loseit backup --root /tmp/explicit-cli ... --dry-run | grep root
  root:               /tmp/explicit-cli                             ← CLI flag wins

Full unit suite: 276/276 green (4 tests had hard-coded ~/.local/share/loseit/ path expectations; updated to match).

What this does NOT do

  • No automatic migration. Existing backups under ~/.local/share/loseit/backup/ stay where they are. Users can:
    • re-run loseit backup against the new default (resume-safe, just refetches the missing year-dirs); or
    • mv ~/.local/share/loseit/backup ~/.config/loseit/backup to keep the existing archive.
  • Existing ~/.local/share/loseit/trash.jsonl is also left in place. Users who want to keep the old trash history: mv ~/.local/share/loseit/trash.jsonl ~/.config/loseit/trash.jsonl.

Test plan

  • Reviewer reads the diff (mostly path string swaps).
  • Reviewer confirms --help text mentions the new env vars.
  • Reviewer runs loseit backup --dry-run and confirms the printed root: is under ~/.config/loseit/backup.

Move backup root and trash file under ~/.config/loseit/ so they sit
next to config.yaml and the auth token. Previously they followed XDG
strictly (backup + trash in ~/.local/share/loseit/, config in
~/.config/loseit/), but having two directories per app for ~3 files
is friction without benefit on a single-user workstation.

New defaults:
  ~/.config/loseit/
    config.yaml
    token
    backup/                  <- was ~/.local/share/loseit/backup/
    trash.jsonl              <- was ~/.local/share/loseit/trash.jsonl

Overridable two ways (in addition to the existing --root / --trash-file
flags):
  - $LOSEIT_BACKUP_ROOT     (backup, restore-backup)
  - $LOSEIT_TRASH_FILE      (delete, restore-trash)

Documented in --help via typer's envvar= mechanism, so --help also
shows "[env var: LOSEIT_BACKUP_ROOT]" beside each flag.

Spec doc + README updated to match. Existing backups under
~/.local/share/loseit/backup/ are NOT migrated automatically; users
can either rerun "loseit backup" against the new default (resume-safe)
or move the directory manually.
@phitoduck phitoduck merged commit cf5e486 into main Jun 13, 2026
3 of 4 checks passed
phitoduck added a commit that referenced this pull request Jun 13, 2026
Two ruff failures kept CI red on main after the delete-safeguards
merge (PR #62) and the path-consolidation merge (PR #72):

  - UP035: src/lose_it/backup/_upsert.py imported Iterable from typing.
    Pyupgrade rule says use collections.abc.Iterable.
  - I001: after the swap, the import block became un-sorted.

Both fixed; ruff check is now clean. Tests stay at 276/276.
phitoduck added a commit that referenced this pull request Jun 13, 2026
Two ruff failures kept CI red on main after the delete-safeguards
merge (PR #62) and the path-consolidation merge (PR #72):

  - UP035: src/lose_it/backup/_upsert.py imported Iterable from typing.
    Pyupgrade rule says use collections.abc.Iterable.
  - I001: after the swap, the import block became un-sorted.

Both fixed; ruff check is now clean. Tests stay at 276/276.
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