Skip to content

Add archive command (C-Archive extension) - #6

Open
jingyucodes wants to merge 1 commit into
masterfrom
add-task-archiving
Open

jingyucodes wants to merge 1 commit into
masterfrom
add-task-archiving

Conversation

@jingyucodes

Copy link
Copy Markdown
Owner

Summary

  • Adds an archive command that moves every task in the active list into a separate, cumulative archive file (data/archive.txt, a sibling of the main save file) and empties the active list.
  • TaskList#clearAll() empties the list and returns what was removed.
  • Storage#archive() appends the removed tasks' save-file lines to the archive file (creating it if needed); previously archived tasks are kept, so repeated archiving accumulates rather than overwriting. Storage's file-creation logic is now shared via a parameterised ensureFileExists(Path) instead of duplicating it for the new archive path.
  • Ui#showArchived() confirms the count, or says there's nothing to archive if the list was already empty.
  • This is the C-Archive pick for the course's BCD-Extension task, tagged BCD-Extension on the implementing commit.

Test plan

  • ./gradlew clean test checkstyleMain checkstyleTest — 22/22 tests pass (including new TaskListTest/StorageTest), checkstyle clean
  • Manually walked through every row of tests/test-plan.md against the built classes (normal archive, empty-list message, cumulative append across separate runs, reload-shows-empty) — all match expected output verbatim
  • Regression-checked all other existing commands (todo/deadline/event/mark/unmark/delete/find/on/list) end-to-end — no behavior change

Echo has no way to clear out old tasks without deleting them for
good, and the tP this feeds into (TutorContacts) lists archiving as
a core MVP feature for contacts, so this is worth practicing the
pattern for here first.

Add an "archive" command that moves every task in the active list
into a separate, cumulative archive file (data/archive.txt, a
sibling of the main save file) and empties the active list:
- TaskList#clearAll() empties the list and returns what was removed.
- Storage#archive() appends the removed tasks' save-file lines to
  the archive file, creating it if needed; existing archived tasks
  are kept, so repeated archiving accumulates rather than
  overwriting. The save/load/archive file-creation logic is now
  shared via a parameterised ensureFileExists(Path) instead of
  duplicating it for the new archive path.
- Ui#showArchived() confirms the count, or says there's nothing to
  archive if the list was already empty.

Added TaskListTest (clearAll on a non-empty/empty list) and
StorageTest (archive appends correctly, and accumulates across
multiple calls, using @tempdir). Also added tests/test-plan.md
(didn't exist before; added covering only this feature) and a
docs/README.md section, leaving the rest of that file's unfilled
placeholder sections untouched since populating them is out of
scope here.
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