Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
add keep flag to prevent cleanup of logs & results
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
chrisvaughn committed Mar 18, 2018
1 parent 951ad40 commit 0150a88
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,17 @@ func run(c *cli.Context) error {
CheckErr("Error: ", err)

logName := dna.getLogfile(dateToProcess)
defer cleanupFiles(logName)
if !c.Bool("keep") {
defer cleanupFiles(logName)
}

ch := dna.readLine(logName)

outFile := "results_" + dateToProcess + ".csv"
outPath := filepath.Join(cfg.Storage.LogDirectory, outFile)
defer cleanupFiles(outPath)
if !c.Bool("keep") {
defer cleanupFiles(outPath)
}
dna.processLine(outPath, ch)

gcsObject := dateToProcess + "_results.csv"
Expand All @@ -329,6 +333,11 @@ func run(c *cli.Context) error {

dna.loadInBQ(gcsObject, dateToProcess)

if c.Bool("keep") {
log.Printf("Log file not removed: %s", logName)
log.Printf("Results file not removed: %s", outPath)
}

return nil
}

Expand All @@ -345,6 +354,10 @@ func main() {
Name: "date, d",
Usage: "process log archive for `YYYY-MM-DD`",
},
cli.BoolFlag{
Name: "keep, k",
Usage: "flag to keep log files after run, helpful during configuration",
},
}
app.Action = run
app.Version = version
Expand Down

0 comments on commit 0150a88

Please sign in to comment.