From 6fffeef88f6716ea544074fd6033f02a1659fde3 Mon Sep 17 00:00:00 2001 From: Lucas dos Santos Abreu Date: Tue, 23 Jul 2024 07:58:13 -0300 Subject: [PATCH] (wip) --- pkg/cmd/time-entry/util/from-defaults.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/cmd/time-entry/util/from-defaults.go diff --git a/pkg/cmd/time-entry/util/from-defaults.go b/pkg/cmd/time-entry/util/from-defaults.go new file mode 100644 index 00000000..e0757d7f --- /dev/null +++ b/pkg/cmd/time-entry/util/from-defaults.go @@ -0,0 +1,23 @@ +package util + +import ( + "github.com/lucassabreu/clockify-cli/pkg/cmd/time-entry/util/defaults" + "github.com/lucassabreu/clockify-cli/pkg/cmdutil" +) + +// FromDefaults starts a TimeEntryDTO with the current defaults +func FromDefaults(f cmdutil.Factory) Step { + return func(ted TimeEntryDTO) (TimeEntryDTO, error) { + d, err := f.TimeEntryDefaults().Read() + if err != nil && err != defaults.DefaultsFileNotFoundErr { + return ted, err + } + + ted.ProjectID = d.ProjectID + ted.TaskID = d.TaskID + ted.TagIDs = d.TagIDs + ted.Billable = d.Billable + + return ted, nil + } +}