8000 GitHub - bethropolis/dir-dumper: A command-line utility to aggregate the content of files within a directory tree into a single file.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A command-line utility to aggregate the content of files within a directory tree into a single file.

License

Notifications You must be signed in to change notification settings

bethropolis/dir-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dir-Dumper

Go Report Card GitHub release (latest by date) GitHub license Go Reference GitHub stars GitHub issues Go Version

dir-dumper is a command-line tool written in Go that recursively traverses a directory, reads the content of non-ignored files, and prints them to standard output or a specified file. It respects .gitignore rules, hidden file conventions, and provides various filtering and formatting options.

The primary goal is to easily aggregate the content of a project's codebase or configuration files into a single block of text, useful for sharing context, documentation, or feeding into other tools (like Large Language Models).

Features

  • Recursive Traversal: Scans directories and subdirectories.
  • .gitignore Aware: Respects rules defined in .gitignore files found within the scanned directory tree.
  • Hidden File Handling: Option to ignore or include hidden files and directories (those starting with .).
  • Filtering:
    • Filter included files by extension (-ext).
    • Define custom ignore patterns (-ignore).
    • Set maximum file size limits (-max-size).
  • Output Formats:
    • Standard plain text (default).
    • JSON output (-json).
    • Markdown output (-markdown).
  • Concurrency: Optional parallel processing for faster scans (-concurrent).
  • Customizable: Numerous flags to control behavior (see Usage).
  • Tracking: Option to display a summary of skipped files and reasons (-show-skipped).
  • Progress: Optional progress display for long scans (-progress).
  • Timeout: Set a maximum execution time (-timeout).
  • Cross-Platform: Built with Go, runs on Linux, macOS, and Windows.

Installation

Using go install (Recommende 8000 d)

If you have Go (1.21+) installed and configured:

go install github.com/bethropolis/dir-dumper/cmd/dir-dumper@latest

Note

This will download the source code, compile it, and place the dir-dumper binary in your $GOPATH/bin directory (usually $HOME/go/bin). Ensure this directory is in your system's PATH.

From Source

  1. Clone the repository:
    git clone https://github.com/bethropolis/dir-dumper.git
    cd dir-dumper
  2. Build the binary:
    go build -o dir-dumper ./cmd/dir-dumper/
  3. (Optional) Move the binary to a directory in your PATH:
    # Example: move to ~/.local/bin 
    mv dir-dumper ~/.local/bin/

Usage

dir-dumper [flags]

Note

By default, dir-dumper scans the current directory (.) and prints the content of non-ignored files to standard output.

Examples
  • Scan the current directory:
    dir-dumper
  • Scan a specific directory:
    dir-dumper -dir /path/to/your/project
  • Only include Go and Markdown files:
    dir-dumper -ext go,md
  • Ignore all .log files and the dist/ directory, in addition to .gitignore rules:
    dir-dumper -ignore "*.log,dist/"
  • Include hidden files (usually ignored):
    dir-dumper -hidden=false
  • Output to a file:
    dir-dumper -output project_dump.txt
  • Output in JSON format:
    dir-dumper -json -output dump.json
  • Output in Markdown format:
    dir-dumper -markdown -output dump.md
  • Use concurrent processing and show progress:
    dir-dumper -concurrent -progress
  • Show skipped files at the end:
    dir-dumper -show-skipped
  • Set a 5-minute timeout:
    dir-dumper -timeout 5m
  • Combine multiple options:
    dir-dumper -dir ../other-project -ext go,mod -ignore "vendor/,*_test.go" -concurrent -output ../dump.txt
Flags
Flags:
      -concurrent
                        Enable concurrent file processing
      -dir string
                        The root directory to scan (default ".")
      -ext string
                        Only include files with these extensions (comma-separated, e.g., 'go,md,txt')
      -git
                        Ignore .git directories (default true)
      -hidden
                        Ignore hidden files/directories (starting with '.') (default true)
      -ignore string
                        Custom ignore patterns (comma-separated, gitignore syntax)
      -json
                        Output results in JSON format
      -log-level string
                        Set the logging level (DEBUG, INFO, WARN, ERROR) (default "INFO")
      -markdown
                        Output results in Markdown format
      -max-size int
                        Max file size to process in MB (0 = no limit)
      -no-color
                        Disable color output
      -output string
                        Output to file instead of stdout
      -progress
                        Show progress information
      -quiet
                        Suppress INFO messages (only show WARN, ERROR)
      -show-skipped
                        Show a list of skipped files/directories and reasons at the end
      -timeout duration
                        Maximum execution time (e.g., '30s', '5m')
      -verbose
                        Enable verbose logging (DEBUG, WARN, ERROR)
      -version
                        Show version information
      -workers int
                        Max number of concurrent workers (defaults to number of CPU cores)

Development

Prerequisites

  • Go 1.21 or later

Building

go build -o dir-dumper ./cmd/dir-dumper/

Pre-built Binaries (Optional)

Pre-built binaries for Linux, macOS, and Windows are available on the Releases page.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

License

This project is licensed under the MIT License.

About

A command-line utility to aggregate the content of files within a directory tree into a single file.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0