pacont

Crates.iopacont
lib.rspacont
version0.5.3
created_at2025-11-04 08:28:05.798737+00
updated_at2025-11-04 08:28:05.798737+00
descriptionCLI tool to gather code context for LLMs
homepage
repositoryhttps://github.com/Tmpecho/pacont
max_upload_size
id1915948
size59,579
Johannes Aamot-Skeidsvoll (Tmpecho)

documentation

README

Pacont

A tool to easily gather code context to give to an AI like ChatGPT or Claude.


Release License Rust Platform

Overview

Pacont (short for Path and Content) is a simple and efficient CLI tool designed to recursively print file paths and their contents within specified directories or files. This tool is particularly useful for gathering code context to provide to AI models like ChatGPT or Claude, making it easier to analyze and understand large codebases.

Features

  • Recursively traverse directories and subdirectories.
  • Print file paths relative to the input directory.
  • Output the contents of each file.
  • Accept multiple directories and files as input, concatenating their contents with a separator.
  • Control maximum recursion depth.
  • Include error messages in the output for files that cannot be read.

Installation

Prerequisites

  • Rust and Cargo installed. If you haven't installed Rust yet, you can do so by running:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Build from Source

  1. Clone the repository:
git clone https://github.com/Tmpecho/pacont.git
cd pacont
  1. Build the project:
cargo build --release
  1. Move the executable to a directory in your PATH:

MacOS/Linux

sudo cp target/release/pacont /usr/local/bin/pacont

Homebrew Installation

brew tap Tmpecho/pacont
brew install pacont

Linux Clipboard Support

For the --copy flag to work on Linux, you need one of the following clipboard utilities installed:

  • xclip (recommended for X11): sudo apt-get install xclip
  • xsel (alternative for X11): sudo apt-get install xsel
  • wl-copy (for Wayland): Usually included with wl-clipboard package

On most Linux distributions, you can install xclip with:

# Debian/Ubuntu
sudo apt-get install xclip

# Fedora
sudo dnf install xclip

# Arch Linux
sudo pacman -S xclip

Without these utilities, the clipboard functionality will fall back to a native implementation that may not persist after the program exits on some systems.

Usage

pacont [OPTIONS] <PATH>...

Options

  • -m, --max-depth <MAX_DEPTH>: Maximum recursion depth for directories (0 means no recursion) [default: usize::MAX]
  • -i, --include-errors: Include error messages in the output
  • -o, --output-information: Get number of characters, words and non-empty lines of output
  • -c, --copy: Copy the output to clipboard
  • -h, --help: Print help information
  • -V, --version: Print version information

Example

Given a directory structure:

src/
├── div
│   └── test.kt
└── main.kt
README.md
misc/
├── notes.txt

Running pacont src README.md misc/ will output:

**div/test.kt**
//comment

**main.kt**
println("hello")

--------------------------------------------------------------------------------
**README.md**
# Pacont
A very simple CLI tool to recursively print file paths and contents in a directory.

--------------------------------------------------------------------------------
**notes.txt**
Some notes here...

Running pacont -o src README.md misc/ will output:

Total Characters: 1234
Total Words: 234
Total Non-Empty Lines: 56 

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request if you have any improvements or new features to add.

Commit count: 0

cargo fmt