From 665bd389a0a1c8adadcaa1122e846cc81f5ead31 Mon Sep 17 00:00:00 2001 From: T Date: Tue, 5 Aug 2025 11:37:02 -0600 Subject: WIP TUI --- internal/commands/helpers.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 internal/commands/helpers.go (limited to 'internal/commands/helpers.go') 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 -- cgit v1.2.3