Unify is a powerful CLI tool that joins text files from your project into a single, unified document. It uses gitignore-style pattern matching to determine which files to include or exclude, making it perfect for code reviews, documentation, and sharing code snippets.
- Gitignore-style patterns: Familiar syntax for including/excluding files
- Multiple language support: Built-in configurations for popular programming languages
- Custom headers: Format file headers with customizable templates
- Binary file detection: Automatically skips binary files
- Recursive traversal: Process entire directory trees
- Path filtering: Process only specific directories within a project
- Flexible output: Write to file or stdout
# Clone the repository
git clone https://github.com/demkom58/unify.git
cd unify
# Build and install
cargo build --release
cargo install --path .
cargo install unify
Download the latest binary for your platform from the Releases page.
# Create a default configuration file
unify init
# Create a configuration for specific languages
unify init --language rust,js,python
# Join files according to the configuration
unify
# Join only files in specific directories
unify ./src ./lib
# Specify output file
unify -o combined.txt
Unify uses a .unify.toml
file in your project directory for configuration:
ignores = [
# Root-level only patterns
"/node_modules/",
"/build/",
"/dist/",
# Patterns that apply everywhere
".git/",
"*.log",
# Exceptions
"!important.log"
]
recursive = true
header_template = "\n---\nFile: {relative_path}\n---\n"
output = "project.joined.txt"
Option | Description | Default |
---|---|---|
ignores |
Array of gitignore-style patterns | [] |
recursive |
Whether to process subdirectories | true |
header_template |
Template for file headers | "// File: {relative_path}\n" |
output |
Output file name (use "-" for stdout) | "unified.txt" |
{relative_path}
- Path relative to the working directory{file_name}
- Name of the file without the path
USAGE:
unify [OPTIONS] [PATHS]...
unify <SUBCOMMAND>
ARGS:
<PATHS>... Specific directories to process (if not specified, process the whole working directory)
OPTIONS:
-c, --config <CONFIG> Path to the configuration file [default: .unify.toml]
-d, --dir <DIR> Directory to process (defaults to current directory)
-h, --help Print help information
-o, --output <OUTPUT> Path where the unified output will be written
-V, --version Print version information
SUBCOMMANDS:
help Show help about pattern syntax
init Initialize a new .unify.toml config file
# Process all files in current directory using .unify.toml
unify
# Process only specific directories
unify ./src ./include
# Use a custom configuration file
unify -c custom-config.toml
# Specify working directory and output file
unify -d /path/to/project -o unified.txt
# Show pattern syntax help
unify help
Unify uses gitignore-style patterns:
- Lines starting with
#
are comments - Patterns ending with
/
match directories only - Patterns starting with
/
match from the root directory - Patterns starting with
!
negate a previous pattern (include) *
matches any sequence of characters except/
**
matches any sequence of directories
Examples:
*.log
- Ignore all .log files anywhere/node_modules/
- Ignore node_modules at the root onlybuild/
- Ignore all build directories anywhere!important.log
- Include important.log even if ignored by other patterns
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request