From abc041381ef7e1f628d8df459204eeb3d45609bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sun, 7 Feb 2021 14:02:32 -0400 Subject: [PATCH] Fixed #2, removed initial check for existing entries, adding a separate one --- z/entry.go | 2 +- z/finishCmd.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/z/entry.go b/z/entry.go index 801240a..3aec902 100644 --- a/z/entry.go +++ b/z/entry.go @@ -47,7 +47,7 @@ func NewEntry( return Entry{}, err } - if newEntry.IsFinishedAfterBegan() == false { + if id == "" && newEntry.IsFinishedAfterBegan() == false { return Entry{}, errors.New("beginning time of tracking cannot be after finish time") } diff --git a/z/finishCmd.go b/z/finishCmd.go index 2cf7c42..e2dc744 100644 --- a/z/finishCmd.go +++ b/z/finishCmd.go @@ -81,6 +81,11 @@ var finishCmd = &cobra.Command{ } } + if runningEntry.IsFinishedAfterBegan() == false { + fmt.Printf("%s %+v\n", CharError, "beginning time of tracking cannot be after finish time") + os.Exit(1) + } + _, err = database.FinishEntry(user, runningEntry) if err != nil { fmt.Printf("%s %+v\n", CharError, err)