From 9dd2358c2dcfd0834b2f5e85f50274438c6cf09d Mon Sep 17 00:00:00 2001 From: Osvaldo Gago Date: Sat, 9 Sep 2017 08:24:28 +0200 Subject: [PATCH 1/2] Code for -trash --- ecompare.go | 3 +++ functions.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/ecompare.go b/ecompare.go index a54c40b..920478c 100644 --- a/ecompare.go +++ b/ecompare.go @@ -20,6 +20,7 @@ func main() { defer timeTrack(time.Now(), "main") help := flag.Bool("help", false, "Display help") + trash := flag.Bool("trash", false, "Delete files created by ecompare") data := flag.String("data", "emails", "What to compare") filenameA := flag.String("A", "a.txt", "File to do the operations") filenameB := flag.String("B", "b.txt", "File to do the operations") @@ -28,6 +29,8 @@ func main() { if *help == true { helpMe() + } else if *trash == true { + trashFiles() } else { // Read the files to strings diff --git a/functions.go b/functions.go index fbdafa5..6898de8 100644 --- a/functions.go +++ b/functions.go @@ -3,6 +3,7 @@ package main import ( "io/ioutil" "log" + "os" "regexp" "strings" "time" @@ -80,3 +81,10 @@ func stringToFile(fileName string, dat string) { panic(err) } } + +// trashFiles deletes files created by ecompare +func trashFiles() { + os.Remove("in-a-but-not-in-b.txt") + os.Remove("in-b-but-not-in-a.txt") + os.Remove("in-both-a-and-b.txt") +} From 4a15986fa664e2347102c028cd3f033efd84be86 Mon Sep 17 00:00:00 2001 From: Osvaldo Gago Date: Sat, 9 Sep 2017 08:24:52 +0200 Subject: [PATCH 2/2] Documentation for -trash --- README.md | 8 ++++++++ doc.go | 8 ++++++-- help.go | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6cf2f11..fd482ee 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,14 @@ The filenames describe it's content and running the script again will overwrite Open this files with your plain/code text editor and investigate the inconsistencies in both your CRM and mailing programs. +#### Delete files created by ecompare + +To delete the 3 files created by ecompare: + +``` +./ecompare -trash +``` + ## Install 1. Download the [latest version of the binary code](https://github.com/greenpeace/ecompare/releases/) for your operating system to your desktop folder. diff --git a/doc.go b/doc.go index 641b679..c056c95 100644 --- a/doc.go +++ b/doc.go @@ -29,9 +29,9 @@ Compare CSV files Download both files as csvs to the same folder as the script. Then, using the command line run the script as: ./ecompare -data=emails -A=fileA.csv -B=fileB.csv - + -data specifies the type of data to compare. It can be emails, sha256 or dni (Spanish ID numbers) - + -A and -B specify the names of both files. Get details about the comparison @@ -66,6 +66,10 @@ The filenames describe it's content and running the script again will overwrite Open this files with your plain/code text editor and investigate the inconsistencies in both your CRM and mailing programs. +To delete the 3 files created by ecompare: + + ./ecompare -trash + . */ package main diff --git a/help.go b/help.go index a42f031..b029fc9 100644 --- a/help.go +++ b/help.go @@ -34,6 +34,7 @@ Comand line options: -A=fileA.csv File A name -B=fileB.csv File B name -debug=true Debug the script +-trash To delete the 3 files created by ecompare ` fmt.Printf(textToPrint)