# me: Merge My Code
## Features
- **Multi-Directory Support**: Merge files from multiple directories simultaneously.
- **Smart Filtering**: Filter files by extension and size.
- **Multiple Output Formats**: Supports plain text, Markdown, and JSON formats.
- **Preview Mode**: List files to be processed without actually merging them.
- **Flexible Configuration**: Supports strict case-sensitive matching and symbolic link following.
- **Detailed Logging**: Multi-level log output for easy debugging.
- **Optional Features**: Supports exclusion patterns, hexadecimal output, and other optional features.
## Installation
### Install via Cargo (Recommended)
```bash
cargo install me
```
### Install from Source
```bash
git clone https://github.com/YOUR_USERNAME/me.git
cd me
cargo install --path .
```
## Quick Start
### Basic Usage
```bash
# Merge all supported files in the current directory into result.txt
me .
# Merge multiple directories
me ./src,./tests,./examples
# Specify an output filename
me . -o combined.txt
```
### Preview Mode (No Actual Merge)
```bash
# List files that would be processed
me . --preview
# Preview multiple directories
me ./src,./tests --preview
```
## Advanced Usage
### File Filtering
```bash
# Merge only files with specific extensions
me . -e rs,toml,md
# Enable strict case-sensitive matching
me . -e RS,Toml --strict-case
# Limit file size (KB)
me . --max-file-size 1024 # Only process files smaller than 1MB
```
### Output Format
```bash
# Markdown format (suitable for documentation)
me . --format markdown -o code.md
# JSON format (suitable for programmatic processing)
me . --format json -o metadata.json
# Plain text format (default)
me . --format plain-text -o code.txt
```
### Symbolic Link Handling
```bash
# Follow symbolic links
me . --follow-links
```
### Verbose Output
```bash
# Different levels of verbosity
me . -v # Warning-level logs
me . -vv # Info-level logs
me . -vvv # Debug-level logs
me . -vvvv # Trace-level logs (includes file names and line numbers)
```
## Output Examples
### Markdown Format Output
```markdown
## ./src/main.rs
```rust
use clap::Parser;
mod cli;
mod merge;
fn main() {
// ...
}
```
### JSON Format Output
```json
[
{
"path": "./src/main.rs",
"content": [
"use clap::Parser;",
"",
"mod cli;",
"mod merge;",
"",
"fn main() {",
" // ...",
"}",
]
}
]
```
### Plain Text Format Output
```
FILE: ./src/main.rs
============================================================
use clap::Parser;
mod cli;
mod merge;
fn main() {
// ...
}
```
## Command-Line Options
```
USAGE:
me [OPTIONS] <DIRECTORIES>...
ARGS:
<DIRECTORIES>...
Directories to process (comma-separated or repeated)
Example: me ./src or me ./src,./tests
OPTIONS:
-e, --extensions <EXTENSIONS>
File extensions to include (comma-separated) [default: rs,toml,html,css,js,json,yaml,yml,xml]
Can be used multiple times: -e rs,toml -e md,json
-f, --format <FORMAT>
Output format [default: plain-text] [possible values: plain-text, markdown, json]
-h, --help
Print help information
-o, --output <OUTPUT>
Output file path [default: result.txt]
-p, --preview
Preview mode: only show the list of files to be processed, do not merge
-v, --verbose...
Increase verbosity (use multiple times for more detail)
-v: warning level -vv: info level -vvv: debug level -vvvv: trace level
-V, --version
Print version information
--strict-case
Perform strict case-sensitive matching on file extensions
--max-file-size <MAX_FILE_SIZE>
Maximum file size limit (KB, 0 means no limit) [default: 0]
--follow-links
Follow symbolic links
--allow-hex <ALLOW_HEX> [Optional feature]
Convert binary files to hexadecimal strings (value indicates max length per line, 0 means no limit)
```
## Troubleshooting
### Common Issues
1. **File Encoding Issues**
```
Warning: File is not UTF-8 encoded
```
This warning indicates the file may contain non-text content or use a different encoding. Use the `--allow-hex` feature to handle such files.
2. **File Size Limits**
Use the `--max-file-size` parameter to limit the maximum file size processed, avoiding overly large files.
3. **Permission Issues**
Ensure you have appropriate read permissions for the directories and files you want to read.
### Debugging Information
Use different levels of the `-v` flag for more debugging information:
```bash
# View detailed processing steps
me . -vvv
# View the most detailed trace information (including file names and line numbers)
me . -vvvv
```
## Contributing
Contributions are welcome! Please follow these steps:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
---
**Tip**: Use `me --help` to view the complete command-line options and usage instructions.