From cc15b553df04a132bdcfd6d826f9997abd4b334a Mon Sep 17 00:00:00 2001 From: Lieuwe Rooijakkers Date: Tue, 14 Jan 2020 21:55:27 +0100 Subject: [PATCH] display: actually support giving sheet name Also show error when given sheet does not exist. --- main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 9702828..4eb5b21 100644 --- a/main.go +++ b/main.go @@ -211,7 +211,7 @@ func main() { }) commands.AddCommand("display", "show all entries in the given sheet", "[SHEET/all/full (current)]", func() error { - var sheet string + sheet := input.Note switch input.Note { case "": sheet = state.CurrentSheet @@ -224,7 +224,11 @@ func main() { return err } - fmt.Printf("Timesheet: %s\n", state.CurrentSheet) + if len(entries) == 0 { + return fmt.Errorf("Can't find sheet matching \"%s\"", sheet) + } + + fmt.Printf("Timesheet: %s\n", sheet) w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0) fmt.Fprintln(w, "Id\tDay\tStart End\tDuration\tNotes")