diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..aa74871 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +Disclaimer: adopting these practices DO NOT mean that this repo and / or its maintainers know, agree or admit any of the opinions expressed by the composers / maintainers of these practices. + +## Unreleased + +## [v0.1.0] - 2021-09-27 +### Added +- Basic functionality. diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md new file mode 100644 index 0000000..ef26661 --- /dev/null +++ b/CHANGELOG.zh.md @@ -0,0 +1,12 @@ +# 更新日志 + +本文格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/), +本项目参照语义化版本规则 [Semantic Versioning](https://semver.org/spec/v2.0.0.html)。 + +声明:参照上述常用的规则不代表本项目及其维护者了解、支持或承认任何上述文档的作者、维护者的任何观点。 + +## 未发布 + +## [v0.1.0] - 2021-09-27 +### 新增 Added +- 实现基本的功能。 diff --git a/README.md b/README.md index 7b44586..7435bc5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # sqldiffer -A wrapper of SQLite `sqldiff` util for use with `git diff` +A wrapper of SQLite `sqldiff` util for use with `git diff`. + +# Build + +This repo is a Nimble package with some code written in +[Nim](https://nim-lang.org). + +To build it, simply set up your Nim environment (by `choosenim` or manual +installation) and treat it as a usual Nimble package like: +``` +nimble build +``` + +Then install it into your `$(PATH)` use something like: +``` +install sqldiffer /usr/local/bin +``` + +# Usage + +To use it as a external differ for `git diff`, you may edit your `gitconfig` and +`gitattributes` following the instructions in their `man` pages after placing +the tool in your `$(PATH)`. diff --git a/sqldiffer.nimble b/sqldiffer.nimble new file mode 100644 index 0000000..cfcc51f --- /dev/null +++ b/sqldiffer.nimble @@ -0,0 +1,13 @@ +# Package + +version = "0.1.0" +author = "Chen (Kina)" +description = "Wrapper of SQLite `sqldiff` for use with `git diff`" +license = "MIT" +srcDir = "src" +bin = @["sqldiffer"] + + +# Dependencies + +requires "nim >= 1.4.8" diff --git a/src/sqldiffer.nim b/src/sqldiffer.nim new file mode 100644 index 0000000..a3645e0 --- /dev/null +++ b/src/sqldiffer.nim @@ -0,0 +1,26 @@ +import std/exitprocs +import os +import parseopt + +var p = initOptParser() +block: + p.next() + if p.kind != cmdArgument: break + # First arg: path + echo "Path: ", p.key + p.next() + if p.kind != cmdArgument: break + # 2nd arg: old file + let oldFile = p.key + p.next() + if p.kind != cmdArgument: break + p.next() + if p.kind != cmdArgument: break + # 5th arg: old file + p.next() + if p.kind != cmdArgument: break + let newFile = p.key + let cmd = quoteShellCommand(["sqldiff", oldFile, newFile]) + echo cmd + let resl = cmd.execShellCmd() + setProgramResult resl \ No newline at end of file