Project Code Combiner is a command-line tool that combines source code files in a project directory into a single file or copies the combined code to the clipboard. This tool is useful for combining multiple files into a single file for asking questions to AI models or sharing code snippets.
To install the Project Code Combiner, follow these steps:
-
Download the Binary:
Download the binary for your operating system from the releases page.
-
Extract the Binary:
Extract the downloaded archive to a directory of your choice, for example,
~/pcc
. -
Copy the Binary:
Copy the
pcc
binary to a directory included in your system's PATH, such as/usr/local/bin
:sudo cp ~/pcc/pcc /usr/local/bin/
-
Set Execute Permissions:
Ensure that the binary is executable:
sudo chmod +x /usr/local/bin/pcc
-
Copy the Configuration File:
Copy the example configuration file to your home directory:
cp ~/pcc/pcc_config.example.toml ~/.pcc_config.toml
-
Customize the Configuration File:
Open the configuration file
~/.pcc_config.toml
in a text editor and customize the settings according to your preferences. -
Verify Installation:
Test the installation by running the command from any location:
pcc --version
-
Download the Binary:
Download the binary for Windows from the releases page.
-
Extract the Binary:
Extract the downloaded archive to a directory of your choice, for example,
C:\pcc
. -
Add to System PATH:
Add the directory containing the
pcc.exe
binary to your system's PATH environment variable. This allows you to run the command from any location in the command prompt. -
Copy the Configuration File:
Copy the example configuration file to your user profile directory:
copy C:\pcc\pcc_config.example.toml %USERPROFILE%\.pcc_config.toml
-
Customize the Configuration File:
Open the configuration file
%USERPROFILE%\.pcc_config.toml
in a text editor and customize the settings according to your preferences. -
Verify Installation:
Test the installation by running the command from any location in the command prompt:
pcc --version
To combine files, use the following command in your terminal:
$ pcc [OPTIONS] <PROJECT_DIRECTORY>
You can include options to override the default behavior specified in the configuration file .pcc_config.toml
.
Here are the available command-line options for customizing the execution:
Option | Description |
---|---|
--copy |
Copies the combined source code to the clipboard instead of saving it to a file. |
--save |
Saves the combined source code to a file. File output destinations can override default settings. |
--output_path=<PATH> |
Specifies the output file path for the combined source code. |
--ignore_file_path=<PATH> |
Specifies the ignore file path in .gitignore format. |
--ignore=<PATTERN> |
Adds an additional ignore pattern (can be used multiple times). |
--help |
Displays the help message. |
--version |
Displays the version information. |
--relative |
Uses relative paths for file references (default: true). |
--no-relative |
Uses absolute paths for file references. |
$ pcc </path/to/project> [OPTIONS]
This command processes the files in the specified project directory and performs the default actions (copy to clipboard or save to file) listed in the configuration file .pcc_config.toml
. Override the default action if the following options are given.
$ pcc </path/to/project> --copy
This command processes the files and copies the combined source code directly to the clipboard, without saving it to a file.
$ pcc </path/to/project> --save
This command processes the files and saves the combined source code to the default output file path specified in the configuration file.
$ pcc </path/to/project> --output_path=/path/to/output/file
This command processes the files and saves the combined source code to the specified output file path.
$ pcc </path/to/project> --ignore_file_path=/path/to/custom/ignore.file
This allows you to use a custom ignore file instead of the default ignore patterns specified in the configuration file.
$ pcc </path/to/project> --ignore=*.log --ignore=temp/ --ignore=*.bak
This command processes the files, ignoring files that match the patterns *.log
, temp/
, and *.bak
, in addition to the ignore patterns specified in the configuration file.
$ pcc </path/to/project> --relative
This command processes the files and uses relative paths for file references in the combined source code. This is the default behavior.
$ pcc </path/to/project> --no-relative
This command processes the files and uses absolute paths for file references in the combined source code.
If you prefer to build the binary from the source code, follow these steps:
-
Clone the repository:
git clone https://github.com/kosaki08/project-code-combiner.git cd project-code-combiner
-
Build the binary:
cargo build --release
The binary will be generated in the
target/release
directory. -
Run the tool using
cargo run
:cargo run -- [OPTIONS] <PROJECT_DIRECTORY>
Note the extra
--
aftercargo run
to pass the options and arguments to the tool.
The configuration file .pcc_config.toml
should be placed in the user's home directory. It allows you to specify default settings for the tool.
Example configuration file:
[default]
action = "copy"
output_path = "~/combined_code"
output_file_name = "combined_code.txt"
ignore_patterns = [
"target",
"*.log",
"*.txt",
]
use_relative_paths = true
The ignore file can be written in .gitignore format. You can specify the ignore file path using the --ignore_file_path
option.
To uninstall the tool, remove the binary from the directory where it was copied and delete the configuration file:
sudo rm /usr/local/bin/pcc
rm ~/.pcc_config.toml
To uninstall the tool, remove the pcc.exe
binary from the directory where it was copied, remove the directory from the system's PATH environment variable, and delete the configuration file:
del %USERPROFILE%\.pcc_config.toml
This project is licensed under the MIT License - see the LICENSE file for details.