Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shahariaazam committed Jul 10, 2024
0 parents commit d78c686
Show file tree
Hide file tree
Showing 9 changed files with 775 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [shaharia-lab, shahariaazam]
22 changes: 22 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI/CD

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install dependencies
run: go mod download
- name: Run tests
run: go test -v ./...
57 changes: 57 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Upload Release Assets

on:
release:
types: [created]

permissions:
contents: write
packages: write

jobs:
build-and-upload:
name: Build and Upload Release Assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install dependencies
run: go mod download
- name: Install UPX
run: sudo apt-get update && sudo apt-get install -y upx
- name: Build and Compress
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o cora-linux-amd64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o cora-darwin-amd64 .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o cora-windows-amd64.exe .
upx --best cora-linux-amd64 cora-darwin-amd64 cora-windows-amd64.exe
- name: Upload Linux Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cora-linux-amd64
asset_name: cora-linux-amd64
asset_content_type: application/octet-stream
- name: Upload macOS Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cora-darwin-amd64
asset_name: cora-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload Windows Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./cora-windows-amd64.exe
asset_name: cora-windows-amd64.exe
asset_content_type: application/octet-stream
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Shaharia Lab OÜ

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
125 changes: 125 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Cora

<p align="center">
<img src="https://github.com/shaharia-lab/cora/assets/1095008/9ce070b3-6377-42e8-bac5-516f3a8387fd" alt="Cora Logo">
</p>

**CORA**: **CO**ncatenate and **R**ead **A**ll

**Cora** is a command-line tool for concatenating files in a directory into a single output file. The name CORA stands for **"COncatenate and Read All"** reflecting its primary function of combining multiple files while providing options to include or exclude specific files based on patterns.

## Features

- Recursively walk through directories
- Include or exclude files based on glob patterns
- Customize separators between concatenated files
- Add prefixes to file paths in the output
- Debug mode for detailed logging

## Use Cases

Cora can be incredibly useful in various scenarios, particularly when dealing with large codebases or multiple files that need to be combined. Here are some key use cases:

1. **LLM Context Preparation**: When working with Large Language Models (LLMs) like GPT-3 or GPT-4, providing comprehensive context is crucial for accurate responses. Cora can concatenate an entire codebase into a single file, making it easy to input as context for LLMs. This is especially useful for:
- Code review and analysis
- Generating documentation
- Answering questions about complex codebases

2. **Documentation Generation**: Combine multiple markdown files or source code files to create comprehensive documentation for your project.

3. **Code Auditing**: Merge multiple source files into a single document for easier review and analysis, especially when working with security auditing tools.

4. **Project Submissions**: Combine all relevant files for project submissions in academic or professional settings.

5. **Backup and Archiving**: Create a single file containing all important documents from a directory structure, making it easier to backup or share entire projects.

6. **Log Analysis**: Concatenate multiple log files for comprehensive analysis, while using exclude patterns to filter out irrelevant files.

7. **Content Management**: Combine multiple content pieces (e.g., blog posts, articles) into a single file for bulk editing or publishing.

8. **Data Preprocessing**: Merge multiple data files into a single file for easier processing in data analysis pipelines.

By using Cora, you can streamline these processes, saving time and reducing the complexity of managing multiple files in various scenarios.

## Installation

To install Cora, make sure you have Go installed on your system, then run:

```bash
go install github.com/shaharia-lab/cora@latest
```

This command will download the source code, compile it, and install the `cora` binary in your `$GOPATH/bin` directory. Make sure your `$GOPATH/bin` is added to your system's `PATH` to run `cora` from any location.

## Usage

After installation, you can run Cora from anywhere in your terminal:

```bash
cora [flags]
```

### Flags

- `-s, --source`: Source directory to concatenate files from (required)
- `-o, --output`: Output file to write concatenated files to (required)
- `-e, --exclude`: Glob patterns to exclude (can be specified multiple times)
- `-i, --include`: Glob patterns to include (can be specified multiple times)
- `-d, --debug`: Enable debugging mode
- `-p, --separator`: Separator to use between concatenated files (default: "\n---\n")
- `-x, --path-prefix`: Prefix to add before the path of included files (default: "## ")

### Example

```bash
cora -s /path/to/source -o output.md -e "*.log" -i "*.md" -i "*.txt" -d
```

This command will concatenate all `.md` and `.txt` files from `/path/to/source`, excluding any `.log` files, and save the result to `output.md` with debug logging enabled.

## Development

### Prerequisites

- Go 1.16 or higher

### Building

To build the project locally, run:

```bash
go build
```

### Running Tests

To run the tests, use:

```bash
go test ./...
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- [Cobra](https://github.com/spf13/cobra) - A Commander for modern Go CLI interactions
- [testify](https://github.com/stretchr/testify) - A toolkit with common assertions and mocks that plays nicely with the standard library

## Contact

Shaharia Lab OÜ - [shaharialab.com](https://shaharialab.com) - [email protected]

Project Link: [https://github.com/shaharia-lab/cora](https://github.com/shaharia-lab/cora)
Loading

0 comments on commit d78c686

Please sign in to comment.