Add archive command (C-Archive extension) - #6
Open
jingyucodes wants to merge 1 commit into
Open
jingyucodes wants to merge 1 commit into
jingyucodes wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
archivecommand 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 parameterisedensureFileExists(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.C-Archivepick for the course's BCD-Extension task, taggedBCD-Extensionon the implementing commit.Test plan
./gradlew clean test checkstyleMain checkstyleTest— 22/22 tests pass (including newTaskListTest/StorageTest), checkstyle cleantests/test-plan.mdagainst the built classes (normal archive, empty-list message, cumulative append across separate runs, reload-shows-empty) — all match expected output verbatimtodo/deadline/event/mark/unmark/delete/find/on/list) end-to-end — no behavior change