Skip to content

Commit 7f0ea02

Browse files
committed
Initial Commit
0 parents  commit 7f0ea02

33 files changed

+1226
-0
lines changed

.github/workflows/release.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
permissions:
2+
contents: write
3+
4+
name: Build and Release Go Binaries
5+
6+
on:
7+
release:
8+
types: [ created ]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
os: [ linux, windows, darwin ]
17+
arch: [ amd64, arm64 ]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Extract Go Version from go.mod or set default
24+
id: go_version
25+
run: |
26+
go_version=$(grep -m 1 '^go ' go.mod | awk '{print $2}')
27+
if [ -z "$go_version" ]; then
28+
echo "Go version not found in go.mod. Using default version 1.24.3."
29+
go_version="1.24.3"
30+
fi
31+
echo "GO_VERSION=$go_version" >> $GITHUB_ENV
32+
echo "Go version: $go_version"
33+
34+
- name: Get Latest Git Tag
35+
id: git_tag
36+
run: |
37+
latest_tag=$(git describe --tags --abbrev=0 || echo "v0.0.0")
38+
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
39+
echo "Latest tag: $latest_tag"
40+
41+
- name: Set up Go
42+
uses: actions/setup-go@v2
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
46+
- name: Run Unit Tests
47+
run: |
48+
go test ./... -v
49+
50+
- name: Build, Archive, and Checksum
51+
run: |
52+
bin_name=csv-diff-${{ matrix.os }}-${{ matrix.arch }}
53+
if [ "${{ matrix.os }}" = "windows" ]; then
54+
bin_name="${bin_name}.exe"
55+
fi
56+
57+
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags "-X main.version=${{ env.LATEST_TAG }}" -o $bin_name ./app/cmd
58+
59+
if [ "${{ matrix.os }}" = "windows" ]; then
60+
archive_name="${bin_name%.exe}.zip"
61+
zip -r "$archive_name" "$bin_name"
62+
else
63+
archive_name="${bin_name}.tar.gz"
64+
tar -czf "$archive_name" "$bin_name"
65+
fi
66+
67+
sha256sum "$bin_name" > "${bin_name}.sha256"
68+
sha256sum "$archive_name" > "${archive_name}.sha256"
69+
70+
echo "BIN_NAME=$bin_name" >> $GITHUB_ENV
71+
echo "ARCHIVE_NAME=$archive_name" >> $GITHUB_ENV
72+
shell: bash
73+
74+
- name: Upload release assets
75+
uses: softprops/action-gh-release@v1
76+
with:
77+
files: |
78+
${{ env.BIN_NAME }}
79+
${{ env.ARCHIVE_NAME }}
80+
${{ env.BIN_NAME }}.sha256
81+
${{ env.ARCHIVE_NAME }}.sha256
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
*.test
8+
*.out
9+
10+
# Output of `go build`
11+
/bin/
12+
/build/
13+
/dist/
14+
15+
# Vendor directory for dependencies (if not committed)
16+
vendor/
17+
18+
# Go workspace file
19+
go.work
20+
go.work.sum
21+
22+
# Test binary and coverage files
23+
*.cover
24+
*.coverprofile
25+
*.cov
26+
*.log
27+
28+
# IDE/editor specific
29+
.idea/
30+
.vscode/
31+
*.swp
32+
*.swo
33+
*~
34+
35+
# OS generated files
36+
.DS_Store
37+
Thumbs.db
38+
39+
# Environment files
40+
.env

CODE_OF_CONDUCT.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and maintainers pledge to make participation in our project and our community a
6+
harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and
7+
expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
8+
9+
We are committed to making participation in this project a harassment-free experience for everyone, and we expect
10+
everyone involved in the project to be respectful and considerate.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to a positive environment for our community include:
15+
16+
- Using welcoming and inclusive language
17+
- Being respectful of differing viewpoints and experiences
18+
- Gracefully accepting constructive criticism
19+
- Focusing on what is best for the community
20+
- Showing empathy towards other community members
21+
22+
Examples of unacceptable behavior by participants include:
23+
24+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
25+
- Trolling, insulting/derogatory comments, and personal or political attacks
26+
- Public or private harassment
27+
- Publishing others' private information, such as a physical or email address, without permission
28+
- Other conduct which could reasonably be considered inappropriate in a professional setting
29+
30+
## Our Responsibilities
31+
32+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
33+
appropriate and fair corrective action in response to any instances of unacceptable behavior.
34+
35+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
36+
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
37+
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
38+
39+
## Enforcement
40+
41+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending email
42+
to [project team](mailto:manishjalui11@gmail.com). All complaints will be reviewed and investigated and will result in a
43+
response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain
44+
confidentiality with regard to the reporter of an incident.
45+
46+
## Attribution
47+
48+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4,
49+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
50+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Manish Jalui
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.PHONY: build test test-race run clean help
2+
3+
build:
4+
go build -o csv-diff ./app/cmd
5+
6+
test:
7+
go test ./...
8+
9+
test-race:
10+
go test -race -cover ./...
11+
12+
run: build
13+
./csv-diff -c ./sample/file1.csv ./sample/file2.csv
14+
15+
clean:
16+
rm -f csv-diff
17+
18+
help:
19+
@echo "Available targets:"
20+
@echo " build Build the csv-diff binary"
21+
@echo " test Run unit tests"
22+
@echo " test-race Run tests with race detector and coverage"
23+
@echo " run Build and run csv-diff with sample files"
24+
@echo " clean Remove built binaries"

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# CSV-DIFF
2+
3+
**CSV-DIFF** is a powerful and flexible CLI tool written in Go for comparing two CSV files. It highlights added,
4+
deleted, updated, and reordered rows based on configurable composite keys. It’s useful for tracking changes in tabular
5+
data like exports from databases, spreadsheets, or APIs.
6+
7+
---
8+
9+
## 📑 Table of Contents
10+
11+
- [Features](#-features)
12+
- [Installation](#-installation)
13+
- [Usage](#-usage)
14+
- [Makefile](#-makefile)
15+
- [License](#-license)
16+
- [Contributing](#-contributing)
17+
- [Code of Conduct](#-code-of-conduct)
18+
19+
---
20+
21+
## 📌 Features
22+
23+
- Compare two CSV files and identify:
24+
- Added, deleted, updated, or reordered rows
25+
- Use composite keys to match rows across files
26+
- Output results in JSON or CSV
27+
- Filter output to focus on specific change types
28+
- Optionally include unchanged rows
29+
- Easy to use via CLI flags
30+
31+
---
32+
33+
## 🛠️ Installation
34+
35+
### Install via `go install`
36+
37+
Make sure you have [Go](https://golang.org/dl/) installed.
38+
39+
```bash
40+
go install github.com/manishjalui11/csv-diff@latest
41+
```
42+
43+
This will install csv-diff into your $GOPATH/bin.
44+
45+
---
46+
47+
## 🚀 Usage
48+
49+
```bash
50+
csv-diff [flags] <original.csv> <new.csv>
51+
```
52+
53+
### Example
54+
55+
```bash
56+
csv-diff -k 0,1 -s json -o diff.json file_old.csv file_new.csv
57+
```
58+
59+
### CLI Flags
60+
61+
| Flag | Short | Description |
62+
|---------------------|-------|-------------------------------------------------------------------------------|
63+
| --save | -s | Format to save output (json or csv) |
64+
| --output | -o | Filename to save changes |
65+
| --key | -k | Comma-separated list of column indexes to use as a composite key (default: 0) |
66+
| --show-changes | -c | Show detailed changes |
67+
| --include-unchanged | -z | Include unchanged rows in the output |
68+
| --filter-added | -a | Only show added rows |
69+
| --filter-deleted | -d | Only show deleted rows |
70+
| --filter-updated | -u | Only show updated rows |
71+
| --filter-reordered | -r | Only show reordered rows |
72+
| --help | -h | Show usage/help information |
73+
| --version | -v | Show app version |
74+
75+
---
76+
77+
## 🧰 Makefile
78+
The project includes a Makefile to simplify common development tasks.
79+
80+
Common Targets
81+
```bash
82+
make build # Build the csv-diff binary
83+
make test # Run tests
84+
make test-race # Run tests with race detection and coverage
85+
make run # Build and run csv-diff with sample files
86+
make clean # Remove built binaries
87+
make help # Show available targets
88+
```
89+
You can always run make help to list all available targets.
90+
91+
---
92+
93+
## 📄 License
94+
95+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.
96+
97+
---
98+
99+
## 🤝 Contributing
100+
101+
We welcome contributions from the community! Whether it's bug fixes, new features, or improvements, your help is
102+
appreciated.
103+
104+
To get started:
105+
106+
1. **Fork the repository** and create your branch (`git checkout -b feature-branch`).
107+
2. **Make your changes** and test them thoroughly.
108+
3. **Commit your changes** with clear and concise commit messages.
109+
4. **Push to your fork** (`git push origin feature-branch`).
110+
5. **Open a Pull Request** describing your changes and why they're useful.
111+
112+
If you encounter any issues or have ideas for new features,
113+
please [open an issue](https://github.com/manishjalui11/csv-diff/issues) or submit a feature request.
114+
115+
By contributing, you agree to follow the project's coding guidelines and adhere to our code of conduct.
116+
117+
Thank you for being awesome and helping improve the project! 🙌
118+
119+
---
120+
121+
## 📜 Code of Conduct
122+
123+
We are committed to creating a welcoming environment for all contributors. Please review and follow
124+
our [Code of Conduct](./CODE_OF_CONDUCT.md).

app/cmd/main.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/manishjalui11/csv-compare/app/pkg/analyser"
6+
"github.com/manishjalui11/csv-compare/app/pkg/flagpkg"
7+
"github.com/manishjalui11/csv-compare/app/pkg/spinner"
8+
"os"
9+
"os/exec"
10+
)
11+
12+
var version = "1.0.0"
13+
14+
func main() {
15+
version = getGitTag()
16+
17+
inputFlags := flagpkg.New()
18+
if ok := inputFlags.Parse(version); !ok {
19+
os.Exit(1)
20+
}
21+
22+
spinnerObj := spinner.NewSpinner()
23+
defer spinnerObj.Stop()
24+
25+
file1, file2 := inputFlags.GetFilePaths()
26+
err := analyser.CompareCSVDetailed(file1, file2, inputFlags.GetSaveFormat(), inputFlags.GetOutputFilename(), inputFlags.ShowChangesEnabled(), inputFlags.IncludeUnchangedEnabled(), inputFlags.GetFilterMap(), inputFlags.GetParsedKeyIndexes())
27+
if err != nil {
28+
fmt.Println("Error comparing CSVs:", err)
29+
return
30+
}
31+
}
32+
33+
func getGitTag() string {
34+
cmd := exec.Command("git", "describe", "--tags", "--abbrev=0")
35+
output, err := cmd.CombinedOutput()
36+
if err != nil {
37+
return version
38+
}
39+
return string(output)
40+
}

0 commit comments

Comments
 (0)