Copy directory(tree)#103
Conversation
Reviewer's GuideThis PR introduces a new “copy” mode to Snaggle by adding a Copy() option and corresponding CLI flag, wiring it through the core Sequence diagram for Snaggle execution with --copy flagsequenceDiagram
actor User
participant CLI
participant Snaggle
participant FileSystem
User->>CLI: Run 'snaggle --copy [options] SRC DEST'
CLI->>Snaggle: Call Snaggle(path, root, opts...)
Snaggle->>Snaggle: Validate options (copy, inplace, etc)
Snaggle->>FileSystem: Copy directory contents to destination
Snaggle->>CLI: Return result/output
ER diagram for expected files in copy mode test caseserDiagram
TESTCASE {
string Src
string Dest
string[] ExpectedStdout
string ExpectedFiles
string Options
string Flags
}
TESTDETAILS {
string Path
bool InSubdir
}
TESTCASE ||--o{ TESTDETAILS : contains
TESTCASE ||--|{ ExpectedFiles : maps
TESTCASE ||--|{ Options : uses
TESTCASE ||--|{ Flags : uses
Class diagram for updated options and Option functions in SnaggleclassDiagram
class options {
+bool copy
+bool inplace
+bool recursive
+bool verbose
}
class Option {
<<function>>
}
Option <|.. Copy
Option <|.. InPlace
Option <|.. Recursive
Option <|.. Verbose
Copy : +func Copy() Option
InPlace : +func InPlace() Option
Recursive : +func Recursive() Option
Verbose : +func Verbose() Option
Class diagram for new error handling in copy modeclassDiagram
class InvocationError {
+string Path
+string Target
+error err
+func Error() string
}
class ErrCopyInplace {
<<variable>>
}
InvocationError --|> error
InvocationError : +Error() string
ErrCopyInplace : errors.New("cannot copy in-place")
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The new directory‐copy tests in TestCases are deeply nested and verbose—consider extracting them into a separate, table-driven helper to reduce duplication and improve readability.
- You’re shadowing the built-in
copyidentifier with a package-levelcopyflag—rename it (e.g.copyFlag) to avoid confusion. - Move the mutual-exclusion check for
--copyand--in-placeup into the CLI’s RunE so users get immediate feedback before any core logic runs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new directory‐copy tests in TestCases are deeply nested and verbose—consider extracting them into a separate, table-driven helper to reduce duplication and improve readability.
- You’re shadowing the built-in `copy` identifier with a package-level `copy` flag—rename it (e.g. `copyFlag`) to avoid confusion.
- Move the mutual-exclusion check for `--copy` and `--in-place` up into the CLI’s RunE so users get immediate feedback before any core logic runs.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #103 +/- ##
==========================================
+ Coverage 74.93% 77.17% +2.24%
==========================================
Files 12 12
Lines 730 828 +98
==========================================
+ Hits 547 639 +92
- Misses 125 130 +5
- Partials 58 59 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by Sourcery
Add a new Copy option and --copy flag to replicate entire directory trees to the destination, enforce mutual exclusion between copy and in-place modes, and update tests and documentation accordingly.
New Features:
Enhancements:
Documentation:
Tests: