Skip to content

Commit 8dace23

Browse files
committed
Added q case i bubble tea program model; added functionality in artifact list command that handles the q command
Signed-off-by: Patrick Eschenbach <patrickeschenbach96@gmail.com>
1 parent 97c20c0 commit 8dace23

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

cmd/harbor/root/artifact/list.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,26 @@ Supports pagination, search queries, and sorting using flags.`,
5353
if len(args) > 0 {
5454
projectName, repoName = utils.ParseProjectRepo(args[0])
5555
} else {
56-
projectName = prompt.GetProjectNameFromUser()
57-
repoName = prompt.GetRepoNameFromUser(projectName)
56+
for {
57+
projectName = prompt.GetProjectNameFromUser()
58+
if projectName == "q" {
59+
fmt.Println("Command cancelled.")
60+
return nil
61+
}
62+
if projectName == "" {
63+
fmt.Println("No project selected. Please select a project or press 'q' to exit.")
64+
continue
65+
}
66+
repoName = prompt.GetRepoNameFromUser(projectName)
67+
if repoName == "q" {
68+
continue
69+
}
70+
if repoName == "" {
71+
fmt.Println("No repository selected. Please select a repository or press 'q' to go back.")
72+
continue
73+
}
74+
break
75+
}
5876
}
5977

6078
artifacts, err = api.ListArtifact(projectName, repoName, opts)

pkg/views/base/selection/model.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8888
m.Choice = string(i)
8989
}
9090
return m, tea.Quit
91+
92+
case "q":
93+
m.Choice = "q"
94+
return m, tea.Quit
9195
}
9296
}
9397

0 commit comments

Comments
 (0)