1
0
Fork 0

Add --verbose flag for real-time file discovery feedback

Implement verbose mode that shows files as they are discovered during
collection rather than just a summary. This provides better user feedback
during the typically slow filesystem traversal phase.

Features:
- Real-time "found: filename" output as files are discovered
- Verbose feedback during collection phase (not archiving phase)
- Simple, focused output that shows filtering effects
- Helps users track progress during potentially slow operations

Changes:
- Add --verbose boolean flag to CLI
- Pass verbose flag to collector constructors
- Display "found: filename" output during file collection
- Add test case to verify verbose output contains expected messages
- Update test suite with helper function to verify output contents
This commit is contained in:
Andrew Tomaka 2025-06-12 22:39:32 -04:00
parent 814e0650de
commit 64a2bbace4
3 changed files with 49 additions and 12 deletions

View file

@ -18,21 +18,24 @@ type FileEntry struct {
type Collector struct {
matcher Matcher
dirFilter DirectoryFilter
verbose bool
}
// New creates a new collector with the specified matcher
func New(matcher Matcher) *Collector {
func New(matcher Matcher, verbose bool) *Collector {
return &Collector{
matcher: matcher,
dirFilter: nil,
verbose: verbose,
}
}
// NewWithDirectoryFilter creates a new collector with the specified matcher and directory filter
func NewWithDirectoryFilter(matcher Matcher, dirFilter DirectoryFilter) *Collector {
func NewWithDirectoryFilter(matcher Matcher, dirFilter DirectoryFilter, verbose bool) *Collector {
return &Collector{
matcher: matcher,
dirFilter: dirFilter,
verbose: verbose,
}
}
@ -98,6 +101,11 @@ func (c *Collector) Collect(sourceDir string) ([]FileEntry, error) {
// Clean the relative path to ensure consistent formatting
relPath = filepath.ToSlash(relPath)
// Show verbose output when file is found
if c.verbose {
fmt.Printf("found: %s\n", relPath)
}
files = append(files, FileEntry{
Path: relPath,
FullPath: path,