Skip to content

Commit 7d9a5f7

Browse files
committed
feat: add support for moving files
This commit introduces the ability to move files using a new `Moved File:` action in the input markdown, enhancing Strux's capabilities for declarative file structure management. The project version has been bumped to `0.3.0` to reflect this new functionality. Key changes include: **Parser:** - Recognizes `## Moved File: <source> to <destination>` and `**Moved File: <source> to <destination>**` headers. - Supports these headers in standalone and wrapped (` ```markdown `) formats. - Handles paths containing the " to " keyword by requiring backtick escaping for such path segments. - `header_utils.rs` was updated to extract source and destination paths for move actions, correctly ignoring trailing comments or descriptions. **Processor:** - Implements a new `process_move` function in `src/processor/move_file.rs` utilizing `std::fs::rename`. - Automatically creates parent directories for the destination path if they don't exist. - Robustly handles various scenarios: - Source file not found (skipped). - Source path is a directory (skipped). - Destination file exists: - Skips if `--force` is not used. - Overwrites if `--force` is used. - Destination path is an existing directory (skipped; the file is not moved into the directory). - Source and destination paths are identical (skipped as a no-op, or "overwritten" if `--force` is used). - Ensures both source and destination paths are within the safe base directory. **Core & CLI:** - Updated `Action`, `ActionType`, and `Summary` data structures to include move-related fields and statuses (e.g., `ActionType::Move`, `Action.dest_path`, `Summary.moved`, `MoveStatus` enum). - The CLI output summary now displays detailed statistics for moved files, overwritten moves, and various skipped move scenarios. - The `--force` option now also applies to overwriting destination files during a move operation. **Documentation & Dependencies:** - `README.md` has been updated to document the new "Moved File" action, its syntax, and examples. - Several core and development dependencies have been updated to their latest patch versions (e.g., `clap`, `assert_cmd`, `bitflags`). Extensive integration and unit tests have been added across the `tests/parser`, `tests/processor`, and `tests/cli` suites to cover the new move functionality, its edge cases, and interactions with existing actions.
1 parent b929610 commit 7d9a5f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1864
-427
lines changed

Cargo.lock

Lines changed: 34 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "strux"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2021"
55
description = "Strux: A CLI tool to generate directory structures and file contents from structured markdown."
66
license = "MIT"

0 commit comments

Comments
 (0)