diff options
author | T <t@tjp.lol> | 2025-08-05 11:37:02 -0600 |
---|---|---|
committer | T <t@tjp.lol> | 2025-08-05 11:37:08 -0600 |
commit | 665bd389a0a1c8adadcaa1122e846cc81f5ead31 (patch) | |
tree | f34f9ec77891308c600c680683f60951599429c3 /internal/commands/helpers.go | |
parent | dc895cec9d8a84af89ce2501db234dff33c757e2 (diff) |
WIP TUI
Diffstat (limited to 'internal/commands/helpers.go')
-rw-r--r-- | internal/commands/helpers.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/commands/helpers.go b/internal/commands/helpers.go new file mode 100644 index 0000000..a0c572b --- /dev/null +++ b/internal/commands/helpers.go @@ -0,0 +1,32 @@ +package commands + +import ( + "context" + "errors" + "punchcard/internal/actions" + "punchcard/internal/queries" +) + +// ErrNoActiveTimer is returned when trying to punch out but no timer is active +var ErrNoActiveTimer = errors.New("no active timer found") + +// Helper functions for commands that need to find clients/projects +// These wrap the actions package for backward compatibility + +func findClient(ctx context.Context, q *queries.Queries, clientRef string) (queries.Client, error) { + a := actions.New(q) + client, err := a.FindClient(ctx, clientRef) + if err != nil { + return queries.Client{}, err + } + return *client, nil +} + +func findProject(ctx context.Context, q *queries.Queries, projectRef string) (queries.Project, error) { + a := actions.New(q) + project, err := a.FindProject(ctx, projectRef) + if err != nil { + return queries.Project{}, err + } + return *project, nil +}
\ No newline at end of file |