diff --git a/cmd/process.go b/cmd/process.go index 76bcf0e..c5f2cca 100644 --- a/cmd/process.go +++ b/cmd/process.go @@ -40,11 +40,7 @@ Formatted data output includes these supplied classifications by default. Any transactions which cannot be automatically classified based on the classifications.json file will be classified as "UNKNOWN" Foratted data can be used elsewhere to understand spending types and remaining budget per classification.`, Run: func(cmd *cobra.Command, args []string) { - startDate, err := time.Parse("20060102", start) - if err != nil { - log.Fatal("Could not parse start date: ", err) - } - startDate = startDate.Add(time.Hour * -24) + startDate := getStartDate(start) transactions.Process(revolutFile, aibFile, startDate) }, } @@ -56,3 +52,15 @@ func init() { processCmd.Flags().StringVarP(&aibFile, "aibFile", "a", "", "The path to the exported AIB statement file") processCmd.Flags().StringVarP(&start, "startDate", "s", "", "The earliest date to be processed (format yyyymmdd)") } + +func getStartDate(start string) time.Time { + if start != "" { + startDate, err := time.Parse("20060102", start) + if err != nil { + log.Fatal("Could not parse start date: ", err) + } + return startDate.Add(time.Hour * -24) + } + + return time.Unix(0, 0) +}