Skip to content

feat: add Compress action - #79

Open
prismatic7 wants to merge 5 commits into
lab421:mainfrom
prismatic7:feat/compress-action
Open

prismatic7 wants to merge 5 commits into
lab421:mainfrom
prismatic7:feat/compress-action

Conversation

@prismatic7

Copy link
Copy Markdown
Contributor

Closes #49.

What

Adds a Compress action alongside Uncompress — the first item on the README roadmap's "planned" list. It zips the matched file or folder into <name>.zip next to it.

Behaviour:

  • Files compress to a single entry; folders keep the folder itself as the wrapper entry, like Finder's "Compress".
  • An existing <name>.zip is never overwritten or skipped — the new archive is numbered (report (1).zip), the same convention as Move/Copy conflicts. The existing archive is left untouched.
  • The source stays in place, exactly like a copy; Undo is not offered, consistent with Uncompress.
  • No options popover (hasOptions == false), per ActionKind.hasOptions's design: the button hides entirely when there's nothing to configure. The issue's destination/timestamp options can layer on later as params if wanted — the schema makes that additive.

Implementation

  • ActionKind.compress in the catalog (Models.swift), wired through RuleSchema (label, icon, group, empty params) — the catalog's exhaustive switches guided every site.
  • ActionExecutor.compress uses ZIPFoundation's FileManager.zipItem (already a dependency via Uncompress) and the shared resolveDestination for numbering; the Dry Run plan case reports the archive as a copiedPath artifact with a rename note when the name was taken.

Three-path consistency (per AGENTS.md)

New action runs through the same plan()/execute() machinery shared by Dry Run, Run Now, and the watcher — no path-specific code touched.

Verification

  • swift build clean.
  • swift test: 333 tests in 28 suites, all passed (330 existing + 3 new).
  • New tests cover: file compress (archive contents + source kept + plan), folder compress (recursive entries, wrapper folder), and existing-archive conflict (numbered name in both plan and execute, original archive intact).
  • Left to CI: the rule editor UI rendering; no GUI run locally.

prismatic7 and others added 5 commits October 24, 2026 01:56
Adds a Compress action alongside Uncompress (issue lab421#49, on the README
roadmap). It zips the matched file or folder into <name>.zip next to it
via ZIPFoundation's zipItem, numbering the archive when the name is
taken (same "name (1).ext" convention as move/copy). The source stays
in place, like a copy, and Undo is not offered — consistent with
Uncompress.

No options popover: an existing archive is always worked around by
numbering, never skipped or replaced. Dry Run reports the archive path,
including the rename, as a copied artifact.

This branch has not been deployed

No deployments
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.

[Feature Request] Add "Compress" / "Archive" action to complement "Uncompress"

2 participants