Skip to main content

Merger is a command-line utility for developers that scans a directory, filters files using customizable ignore patterns, and merges all readable content into a single structured output file.

Project description

Merger CLI

Python License: GPLv3 PyPI

Merger is a command-line utility for developers that scans a directory, filters files using customizable ignore patterns, and merges all readable content into a single output file, suitable both for human reading and for use by AI models.

It supports multiple output formats (e.g., JSON, directory tree, plain text with file delimiters), and can be extended with custom file parsers (e.g., .pdf) and custom exporters (e.g., .xml, .md).


Quick Start

  1. Install the CLI: Download the standalone installer for your OS from Releases.
  2. Verify the installation:
    merger --version
    
  3. Navigate to your project:
    cd path/to/your/project
    
  4. Create an ignore file:
    merger -c PYTHON
    
  5. Run Merger:
    merger .
    
    This creates merger.txt in the current directory.

Features

  • Recursive merge of all readable files under a root directory.
  • Custom glob-like ignore patterns with specialized type qualifiers.
  • Intelligent plugin system: JSON-backed tracking with automatic dependency management via uv.
  • Automatic file encoding detection.
  • Multiple export formats: Built-in support for Plain Text, JSON, Directory Trees, and more.
  • Modern CLI interface: Update notifications and non-interactive mode.

Installation

Standalone Installation (Recommended)

Merger CLI is distributed as standalone binaries.

  • Windows: Download and run merger-cli-windows-installer.exe.
  • Linux (.deb):
    sudo apt install ./merger-cli.deb
    
  • macOS (Homebrew):
    brew tap diogotoporcov/merger-cli
    brew install merger-cli
    

From Source

For developers:

  1. Clone the repository.
  2. Install the API: pip install -e "./packages/merger-plugin-api[test]"
  3. Install the CLI: pip install -e "./packages/merger-cli[test,dev]"

Usage Guide

Output Formats (-e / --exporter)

Exporter Name File Extension Description
TREE_PLAIN_TEXT .txt Directory tree + plain-text merged file contents (default).
PLAIN_TEXT .txt Plain-text merged contents with file delimiters.
TREE .txt Directory tree only.
JSON .json JSON mapping file paths to parsed contents.
JSON_TREE .json Structured JSON with hierarchy and metadata.

Ignore Pattern Syntax

Patterns are relative to the scan root. Merger uses Git-style matching with custom type qualifiers:

  • * matches any number of characters within a path segment.
  • ** matches zero or more directories.
  • Trailing / matches only directories.
  • Trailing : matches only files.
  • Trailing ! disables type qualification (treats trailing / or : as literal).

Examples

  • *.log: Ignore all .log files recursively.
  • dist/: Ignore the dist directory at the root.
  • src/*.py:: Ignore all .py files directly under the src directory.

Detailed Ignore Examples

Merger uses a specialized syntax to distinguish between files and directories, and to handle edge cases where literal characters are needed.

Pattern Type Effect
node_modules/ Directory Ignores the node_modules directory and all its contents.
temp/ Directory Ignores any directory named temp anywhere in the tree.
config.json: File Ignores only files named config.json. A directory named config.json would not be ignored.
tags: File Ignores a file named tags. Useful for ignoring files that don't have extensions.
build!/ Literal Ignores a file or directory named build/ literally (disables the special directory meaning of /).
archive!: Literal Ignores a file or directory named archive: literally.
config!/ Literal Ignores a file or directory named config/ literally.
docs/**/tmp/ Directory Ignores any tmp directory located anywhere inside the docs directory.
src/*.c: File Ignores all .c files directly inside the src directory.
!important.log: Negation The ! at the beginning (before any path) negates the pattern (do not ignore).
README.md!: Literal Ignores a file named README.md:.

Plugins

Merger CLI features a plugin architecture. Plugins are standalone Python files that can define their own dependencies via a REQUIREMENTS list.

Managing Requirements (Bundled Version Only)

If you are using the bundled version of Merger CLI, you can manage plugin requirements manually:

  • Install: merger --install-requirements (Installs all REQUIREMENTS defined in your installed plugins)
  • Purge: merger --purge-requirements (Uninstalls any unused requirements from the plugin environment)

Building Plugins

Plugins are standalone Python files. They can define a REQUIREMENTS list at the top level to specify any external dependencies they need:

REQUIREMENTS = ["pillow", "requests"]

class MyParser:
    ...

CLI Options

Option Description
INPUT_DIR_PATH Root directory to scan.
OUTPUT_FILE_DIR_PATH Directory to save the output (default: .).
-e, --exporter Choose the exporter strategy.
-i, --install-plugin Install a custom parser or exporter plugin.
-u, --uninstall-plugin Uninstall a plugin by ID (use * for all).
-l, --list-plugins List all installed custom plugins.
--install-requirements Install requirements for all installed custom plugins.
--purge-requirements Uninstall all unused requirements from the plugin environment.
--update Check for CLI updates and provide download links.
--ignore Glob-style patterns to ignore.
--merger-ignore Path to ignore file (default: ./merger.ignore).
-c, --create-ignore Create an ignore file from template (e.g., PYTHON, RUST).
-y, --yes Enable non-interactive mode (auto-confirm prompts).

License

This project is licensed under the GPLv3 License — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

merger_cli-4.0.0a11.tar.gz (67.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

merger_cli-4.0.0a11-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file merger_cli-4.0.0a11.tar.gz.

File metadata

  • Download URL: merger_cli-4.0.0a11.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for merger_cli-4.0.0a11.tar.gz
Algorithm Hash digest
SHA256 27f6b93e5d3cf3d1ef73c1b18de745e3c2b17ecd7577fe26d90de14f1aea8829
MD5 f3b658f8f42d9f8dc57e2410fe354d3b
BLAKE2b-256 44a8505c5470d107a6a26463c38ca84cfabcea3a9db480bf76b94dda508a9f04

See more details on using hashes here.

Provenance

The following attestation bundles were made for merger_cli-4.0.0a11.tar.gz:

Publisher: release-cli.yml on diogotoporcov/merger-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file merger_cli-4.0.0a11-py3-none-any.whl.

File metadata

  • Download URL: merger_cli-4.0.0a11-py3-none-any.whl
  • Upload date:
  • Size: 65.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for merger_cli-4.0.0a11-py3-none-any.whl
Algorithm Hash digest
SHA256 ac69357ab5405ec49ce2c4acfbff070717b0cf41ab8ee47bd5b66cbf2622c185
MD5 1e6bb88fcfe05cf687532bbeb1b5bd38
BLAKE2b-256 d614372f956d024c6c4da98fd3ce63c72987c6ee9bcdbc0539fc5eb2c0ee3253

See more details on using hashes here.

Provenance

The following attestation bundles were made for merger_cli-4.0.0a11-py3-none-any.whl:

Publisher: release-cli.yml on diogotoporcov/merger-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page