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/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") +} 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)