@@ -18,11 +18,12 @@ import (
1818)
1919
2020var (
21- csvPath string
22- dryRun bool
23- jiraProject string
24- jiraIssueType string
25- jiraSearchLabel string // defaults to "flaky_test" if empty
21+ csvPath string
22+ dryRun bool
23+ jiraProject string
24+ jiraIssueType string
25+ jiraSearchLabel string // defaults to "flaky_test" if empty
26+ flakyTestJSONDBPath string
2627)
2728
2829// CreateTicketsCmd is the Cobra command that runs a Bubble Tea TUI for CSV data,
@@ -60,7 +61,7 @@ ticket in a text-based UI. Press 'y' to confirm creation, 'n' to skip,
6061 }
6162
6263 // 2) Load local DB (test -> known Jira ticket)
63- db , err := localdb .LoadDB ( )
64+ db , err := localdb .LoadDBWithPath ( flakyTestJSONDBPath )
6465 if err != nil {
6566 log .Warn ().Err (err ).Msg ("Failed to load local DB; continuing with empty DB." )
6667 db = localdb .NewDB ()
@@ -149,11 +150,11 @@ ticket in a text-based UI. Press 'y' to confirm creation, 'n' to skip,
149150 fm := finalModel .(model )
150151
151152 // 9) Save local DB with any new knowledge
152- if err := localdb . SaveDB ( fm .LocalDB ); err != nil {
153+ if err := fm .LocalDB . Save ( ); err != nil {
153154 log .Error ().Err (err ).Msg ("Failed to save local DB" )
154155 } else {
155156 // Let the user know we updated it
156- fmt .Printf ("Local DB has been updated at: %s\n " , localdb .FilePath ())
157+ fmt .Printf ("Local DB has been updated at: %s\n " , fm . LocalDB .FilePath ())
157158 }
158159
159160 // 10) Write remaining CSV
@@ -174,6 +175,7 @@ func init() {
174175 CreateTicketsCmd .Flags ().StringVar (& jiraProject , "jira-project" , "" , "Jira project key (or env JIRA_PROJECT_KEY)" )
175176 CreateTicketsCmd .Flags ().StringVar (& jiraIssueType , "jira-issue-type" , "Task" , "Type of Jira issue (Task, Bug, etc.)" )
176177 CreateTicketsCmd .Flags ().StringVar (& jiraSearchLabel , "jira-search-label" , "" , "Jira label to filter existing tickets (default: flaky_test)" )
178+ CreateTicketsCmd .Flags ().StringVar (& flakyTestJSONDBPath , "flaky-test-json-db-path" , "" , "Path to the flaky test JSON database (default: ~/.flaky_tes_db.json)" )
177179}
178180
179181// -------------------------------------------------------------------------------------
@@ -346,34 +348,29 @@ func updateNormalMode(m model, msg tea.KeyMsg) (tea.Model, tea.Cmd) {
346348 }
347349 t := m .tickets [m .index ]
348350
351+ // Always allow 'q' (quit) and 'e' (enter existing ticket)
349352 switch msg .String () {
350353 case "q" , "esc" , "ctrl+c" :
351354 return updateQuit (m )
355+ case "e" :
356+ m .mode = "promptExisting"
357+ m .inputValue = ""
358+ return m , nil
352359 }
353360
354- // If invalid, we cannot create a new ticket, so no 'y' prompt:
355- if ! t .Valid {
356- // Let user skip or do other actions
361+ // If ticket is valid, allow create ('c') and skip ('n')
362+ if t .Valid {
357363 switch msg .String () {
358- // user might press anything => skip
359- default :
364+ case "c" :
365+ return updateConfirm (m )
366+ case "n" :
360367 return updateSkip (m )
361368 }
362- }
363-
364- // If valid, handle normal flow
365- switch msg .String () {
366- case "y" :
367- return updateConfirm (m )
368- case "n" :
369- return updateSkip (m )
370- case "e" :
371- // always prompt to enter or overwrite
372- m .mode = "promptExisting"
373- m .inputValue = ""
374369 return m , nil
375370 }
376- return m , nil
371+
372+ // For invalid tickets, default to skipping if any other key is pressed.
373+ return updateSkip (m )
377374}
378375
379376func updatePromptExisting (m model , msg tea.KeyMsg ) (tea.Model , tea.Cmd ) {
@@ -491,8 +488,9 @@ func (m model) View() string {
491488 }
492489
493490 // 2) Summary & Description
494- sum := summaryStyle .Render ("Summary:\n " ) + t .Summary
495- descHeader := descHeaderStyle .Render ("\n Description:\n " )
491+ sum := summaryStyle .Render ("Summary:" )
492+ sumBody := descBodyStyle .Render (t .Summary )
493+ descHeader := descHeaderStyle .Render ("\n Description:" )
496494 descBody := descBodyStyle .Render (t .Description )
497495
498496 // 3) Existing ticket line
@@ -527,39 +525,40 @@ func (m model) View() string {
527525 helpLine := ""
528526 // Cases:
529527 // A) If invalid:
530- // B) If valid & there's an existing ticket => [n] to next, [e] to update existing ticket ID , [q] to quit.
531- // C) If valid & no existing => [y ] to confirm , [n] to skip, [e] to enter existing ticket, [q] to quit (with DRY RUN text if needed).
528+ // B) If valid & there's an existing ticket => [n] to next, [e] to update ticket id , [q] to quit.
529+ // C) If valid & no existing => [c ] to create ticket , [n] to skip, [e] to enter existing ticket, [q] to quit (with DRY RUN text if needed).
532530 if ! t .Valid {
533531 if t .ExistingJiraKey != "" {
534- helpLine = faintStyle .Render ("\n [n] to next, [e] to update existing ticket ID , [q] to quit." )
532+ helpLine = faintStyle .Render ("\n [n] to next, [e] to update ticket id , [q] to quit." )
535533 } else {
536534 helpLine = faintStyle .Render ("\n [n] to next, [e] to add existing ticket ID, [q] to quit." )
537535 }
538536 } else {
539537 if t .ExistingJiraKey != "" {
540- helpLine = faintStyle .Render ("\n [n] to next, [e] to update existing ticket ID , [q] to quit." )
538+ helpLine = faintStyle .Render ("\n [n] to next, [e] to update ticket id , [q] to quit." )
541539 } else {
542540 // if no existing ticket, the normal prompt
543541 dryRunLabel := ""
544542 if m .DryRun || m .JiraClient == nil {
545543 dryRunLabel = " (DRY RUN)"
546544 }
547545 helpLine = faintStyle .Render (
548- fmt .Sprintf ("\n Press [y ] to confirm %s, [n] to skip, [e] to enter existing ticket, [q] to quit." ,
546+ fmt .Sprintf ("\n Press [c ] to create ticket %s, [n] to skip, [e] to enter existing ticket, [q] to quit." ,
549547 dryRunLabel ),
550548 )
551549 }
552550 }
553551
554552 return fmt .Sprintf (
555- "%s\n \n %s\n %s%s%s%s\n %s\n " ,
553+ "%s\n %s \n %s\n %s%s%s%s\n %s\n " ,
556554 header ,
557555 sum ,
556+ sumBody ,
558557 descHeader ,
559558 descBody ,
560559 existingLine , // e.g. "Existing ticket found in jira: https://..."
561560 invalidLine , // e.g. "Cannot create ticket: Missing required..."
562- helpLine , // e.g. "[n] to next, [e]... or "[y ] to confirm ..."
561+ helpLine , // e.g. "[n] to next, [e]... or "[c ] to create ticket ..."
563562 )
564563}
565564
0 commit comments