cat-context
Have you ever wanted to ask a question about a project to a LLM but lost a lot of time trying to explain the structure of the project and the relevant files?
cctx is a command-line tool that allows you to recursively print the file tree of a specified directory, display contents of specified files, and ignore certain paths or the entire tree. It's useful for quickly understanding the structure and content of a project in the context of a question.
Features
- Recursively print file trees: Visualize the directory structure of your project.
- Display file contents: Easily view the contents of specified files.
- Ignore paths: Exclude certain files or directories from the tree.
- Ignore entire tree: Focus solely on specified files without displaying the tree.
- Specify line ranges: Display specific lines from files.
Installation
You can install cat-context via pip:
pip install cat-context
This will install the cat-context package and make the cctx command available globally.
Usage
cctx [OPTIONS] [FILE_PATHS...]
Options
--cwd <path>: Change the current working directory. Defaults to the current directory.-ip,--ignore-path <path>: Paths to ignore in the file tree (relative to cwd or absolute). Can be used multiple times to ignore multiple paths.-it,--ignore-tree: Ignore the entire tree and only display specified files.
Arguments
FILE_PATHS: One or more files to display contents of if they exist in the tree. You can specify line numbers using the formatpath:start_line:end_line.
Examples
Display the file tree and the contents of specific files
cctx README.md cctx/main.py
Display contents of specific lines in a file (e.g., lines 10 to 20)
cctx cctx/main.py:10:20
Ignore the tree and only display contents of specified files
cctx --ignore-tree README.md
Ignore specific paths when displaying the tree
cctx --ignore-path=folder1 --ignore-path=folder2
Display the file tree of a specified directory
cctx --cwd=/path/to/directory
Development
If you want to run ctx in development mode or contribute to the project, follow these steps.
Clone the repository
git clone https://github.com/asnunes/ctx.git
cd cctx
Install dependencies
Make sure you have Python 3 installed. It's recommended to use a virtual environment.
python3 -m venv venv
source venv/bin/activate # On Windows use venv\Scripts\activate
Install the package in editable mode
pip install -e .
Run the script
cctx [OPTIONS] [FILE_PATHS...]
Or directly via Python:
python cctx/main.py [OPTIONS] [FILE_PATHS...]
Example
python cctx/main.py --cwd=. README.md
Running Tests
To run the tests, use the unittest module from the root directory.
python -m unittest discover tests
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for cat-context 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cat_context-1.0.0.tar.gz | 6.3 kB | Without provenance | Details for cat_context-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cat_context-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for cat_context-1.0.0-py3-none-any.whl |
Total release size: 13.4 kB
Release files / cat_context-1.0.0.tar.gz
| Download URL | cat_context-1.0.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
363a4a983bf7aa7094c1c6dec9cbf72e45b3511825555041c5ded738631c4593
|
|
BLAKE2b-256 checksum How to use checksums |
bec17a5f4c265e56eefd3e32903227a0cb0791b6f5a2cd8e465bd411cf7ea9d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Release files / cat_context-1.0.0-py3-none-any.whl
| Download URL | cat_context-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41763dd2b1dbbfe75d333ea9dab465c75b0414f677c710e4731f8f3c53e97d10
|
|
BLAKE2b-256 checksum How to use checksums |
5c6110bee3772b25ba31d12c82d762c950c1976dd74f2ad7bcda6cf6ad9c3529
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Security for cat-context 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.