Code Collector is a powerful and flexible tool designed to traverse directories, collect code files, and generate comprehensive reports. It's particularly useful for developers, code reviewers, and anyone needing to analyze or document code structures across projects.
- Directory Traversal: Recursively explore directory structures.
- Selective File Collection: Customize which files to include based on extensions and ignore patterns.
- Git Integration: Clone and analyze GitHub repositories directly.
- Gitignore Support: Respects
.gitignorerules at multiple directory levels. - Flexible Output Formats: Generate reports in JSON, plain text, or Markdown.
- Tree View Generation: Create a visual representation of the directory structure.
- Language Detection: Automatically detect and highlight code based on file type.
- Concurrent Processing: Utilize goroutines for efficient file processing.
- Versioning: Semantic versioning for better release management and compatibility.
To install Code Collector, ensure you have Go installed on your system, then run:
go get -u github.com/Anomalybound/codecollectorTo install a specific version:
go get -u github.com/Anomalybound/codecollector@v1.0.0codecollector -d /path/to/your/directory -o output_file-d, --directory: Path of the folder to traverse (required if not using--github)-o, --output: Output file name without extension (default: "collected_code")--config: Path to configuration file (YAML)--github: GitHub repository URL to clone and process--branch: Branch to clone from GitHub repo (default: "main")--output-format: Output format (json, text, or markdown)-v, --version: Display the current version of Code Collector
To analyze a GitHub repository:
codecollector --github https://github.com/user/repo --branch main -o github_reportYou can use a YAML configuration file to set include extensions and ignore patterns:
include_extensions:
- .go
- .js
- .py
ignore_patterns:
- "vendor/"
- "node_modules/"Use the configuration file with:
codecollector -d /path/to/project --config config.yaml -o configured_outputJSON output includes a tree representation of the directory structure and the content of each collected file.
Plain text output provides a readable format with the directory structure and file contents.
Markdown output creates a structured document with syntax highlighting for code snippets, making it ideal for documentation or sharing on platforms like GitHub.
- Go 1.16 or higher
- Dependencies (automatically installed with
go get):- github.com/go-enry/go-enry/v2
- github.com/go-git/go-git/v5
- github.com/spf13/cobra
- gopkg.in/yaml.v2
-
Clone the repository:
git clone git@github.com:Anomalybound/codecollector.git
-
Navigate to the project directory:
cd codecollector -
Build the project:
go build
Code Collector follows Semantic Versioning. Version numbers are in the format MAJOR.MINOR.PATCH.
To see the current version:
codecollector --versionContributions are welcome! Please feel free to submit a Pull Request.
When contributing, please follow the existing code style and add tests for any new features. Make sure to update the CHANGELOG.md file with your changes under the "Unreleased" section.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any problems or have any questions, please open an issue on the GitHub repository at https://github.com/Anomalybound/codecollector/issues.