@@ -19,6 +19,15 @@ func main() {
1919 metadataJSON := flag .String ("metadata" , "" , "Job metadata as JSON (for client mode)" )
2020 bulkFile := flag .String ("bulk-from-file" , "" , "Bulk insert jobs from JSON file" )
2121 configPath := flag .String ("config" , "" , "Path to config file (default: $HOME/.dprompt.toml)" )
22+
23+ totalGroups := flag .Bool ("total-groups" , false , "Display total number of groups (view mode)" )
24+ groupID := flag .Int ("group" , 0 , "Display results for a specific group ID (view mode)" )
25+ deleteGroupID := flag .Int ("delete-group-id" , 0 , "Delete a specific group ID and all its associated results" )
26+
27+ n := flag .Int ("n" , 10 , "Number of results to display (view mode)" )
28+
29+ queueN := flag .Int ("queue-n" , 10 , "Number of queued jobs to display (for view action)" )
30+ queueAction := flag .String ("action" , "" , "Queue action: 'view' to list queued jobs, 'clear' to delete all queued jobs" )
2231
2332 flag .Parse ()
2433
@@ -39,6 +48,41 @@ func main() {
3948 RunClient (ctx , driver , * argsJSON , * metadataJSON , * bulkFile , dbPool )
4049 case "worker" :
4150 RunWorker (ctx , driver , cancel , dbPool )
51+ case "delete-group" :
52+ if * deleteGroupID == 0 {
53+ log .Fatal ().Msg ("Please provide --delete-group-id" )
54+ }
55+ if err := DeleteGroupAndResults (ctx , dbPool , * deleteGroupID ); err != nil {
56+ log .Fatal ().Err (err ).Msg ("Failed to delete group and results" )
57+ }
58+ log .Info ().Int ("group_id" , * deleteGroupID ).Msg ("Deleted group and associated results" )
59+ case "view" :
60+ if * totalGroups {
61+ if err := viewTotalGroups (ctx , dbPool ); err != nil {
62+ log .Fatal ().Err (err ).Msg ("Failed to get total groups" )
63+ }
64+ } else if * groupID != 0 {
65+ if err := viewResultsByGroup (ctx , dbPool , * groupID ); err != nil {
66+ log .Fatal ().Err (err ).Msg ("Failed to get results by group" )
67+ }
68+ } else {
69+ if err := viewLastResults (ctx , dbPool , * n ); err != nil {
70+ log .Fatal ().Err (err ).Msg ("Failed to get last results" )
71+ }
72+ }
73+ case "queue" :
74+ switch * queueAction {
75+ case "view" :
76+ if err := ViewQueuedJobs (ctx , dbPool , * queueN ); err != nil {
77+ log .Fatal ().Err (err ).Msg ("Failed to view queued jobs" )
78+ }
79+ case "clear" :
80+ if err := ClearQueuedJobs (ctx , dbPool ); err != nil {
81+ log .Fatal ().Err (err ).Msg ("Failed to clear queued jobs" )
82+ }
83+ default :
84+ log .Fatal ().Str ("action" , * queueAction ).Msg ("Unknown queue action" )
85+ }
4286 default :
4387 log .Fatal ().Str ("mode" , * mode ).Msg ("Unknown mode" )
4488 }
0 commit comments