aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-10-25 16:58:57 -0400
committerMitch Riedstra <mitch@riedstra.us>2020-10-25 16:58:57 -0400
commit5640cbe7d1433ff9a7a903f961d6f963c5880080 (patch)
treeb1c743c5588f29109aef9e9668bd20d398dda758
parent7752715a53155e4809f91e5894dfb2e9b3d35544 (diff)
downloaddeduplicator-5640cbe7d1433ff9a7a903f961d6f963c5880080.tar.gz
deduplicator-5640cbe7d1433ff9a7a903f961d6f963c5880080.tar.xz
Add a build script. Basic readme. License file.HEADmaster
-rw-r--r--LICENSE13
-rwxr-xr-xbuild.sh23
-rw-r--r--main.go18
-rw-r--r--readme.md9
4 files changed, 62 insertions, 1 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f92dbaa
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2020 Mitchell Riedstra
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..de7f434
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -e
+
+LICENSE="$(cat LICENSE)"
+
+version="$(git log --format="%h %d" -1)
+$(go version)
+Build Date: $(date)
+Commit Author: $(git log --format="%an" -1)
+Commit date: $(git log --format="%aD" -1)
+
+Source code can be found here:
+https://git.riedstra.dev/mitch/deduplicator
+
+$LICENSE"
+
+if ! git diff-index --quiet HEAD ; then
+ version="dirty: $version"
+fi
+
+export CGO_ENABLED=0
+
+go build -ldflags="-X 'main.VersionString=$version'" -o deduplicator main.go
diff --git a/main.go b/main.go
index a84eadb..737a148 100644
--- a/main.go
+++ b/main.go
@@ -162,6 +162,13 @@ func formatBytes(b int64) string {
return s
}
+var VersionString = ""
+
+func VersionPrint() {
+ fmt.Println(VersionString)
+ os.Exit(0)
+}
+
func main() {
fl := flag.NewFlagSet("deduplicator", flag.ExitOnError)
@@ -173,10 +180,19 @@ func main() {
removeRegexStr := fl.String("regex", "", "Regular expression to match duplicated files")
removeYes := fl.Bool("yes-i-want-my-data-gone", false, "Actually remove the files")
matchPath := fl.Bool("match-path", false, "match on the path, rather than the filename")
- cacheFile := fl.String("cache", "", "If not an empty string, the data gathered on a directory will be cached to the file, allowing subsequent runs to be near instant. No care is taken to check whether or not the cache is up to date with the current state of the directroy. If in doubt, leave empty.")
+ cacheFile := fl.String("cache", "",
+ `If not an empty string, the data gathered on a directory will be cached
+to the file, allowing subsequent runs to be near instant. No care is
+taken to check whether or not the cache is up to date with the current
+state of the directroy. If in doubt, leave empty.`)
+ version := fl.Bool("v", false, "Print the version then exit")
_ = fl.Parse(os.Args[1:])
+ if *version {
+ VersionPrint()
+ }
+
if *remove && *removeRegexStr == "" {
log.Fatal("A regular expression (-regex '<expr>') is required")
}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..ef95f41
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,9 @@
+# Go Deduplicator
+
+Similar to the traditional [fdupes](https://github.com/adrianlopezroche/fdupes)
+command. Though this one is written in go, utilizes sha256, gives you the
+ability to cache the scan and delete the duplicates via a regex.
+
+It's also smart enough not to blow away your files if your regex matches
+all of the files. ( Since the program does not know files you actually
+want to keep )