@@ -17,6 +17,7 @@ import (
1717 tea "github.com/charmbracelet/bubbletea"
1818 "github.com/charmbracelet/huh"
1919 "github.com/stainless-api/stainless-api-cli/pkg/stainlessutils"
20+ "github.com/stainless-api/stainless-api-cli/pkg/stainlessviews"
2021 "github.com/stainless-api/stainless-api-go"
2122 "github.com/stainless-api/stainless-api-go/option"
2223 "github.com/tidwall/gjson"
@@ -34,11 +35,8 @@ type BuildModel struct {
3435 branch string
3536 help help.Model
3637 diagnostics []stainless.BuildDiagnostic
37- downloads map [stainless.Target ]struct {
38- status string
39- path string
40- }
41- view string
38+ downloads map [stainless.Target ]stainlessviews.DownloadStatus
39+ view string
4240
4341 cc * apiCommandContext
4442 ctx context.Context
@@ -97,7 +95,7 @@ func (m BuildModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9795
9896 case downloadMsg :
9997 download := m .downloads [stainless .Target (msg )]
100- download .status = "completed"
98+ download .Status = "completed"
10199 m .downloads [stainless .Target (msg )] = download
102100
103101 case tickMsg :
@@ -112,17 +110,11 @@ func (m BuildModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
112110 case fetchBuildMsg :
113111 if m .build == nil {
114112 m .build = msg
115- m .downloads = make (map [stainless.Target ]struct {
116- status string
117- path string
118- })
113+ m .downloads = make (map [stainless.Target ]stainlessviews.DownloadStatus )
119114 for targetName , targetConfig := range m .cc .workspaceConfig .Targets {
120- m .downloads [stainless .Target (targetName )] = struct {
121- status string
122- path string
123- }{
124- status : "not started" ,
125- path : targetConfig .OutputPath ,
115+ m .downloads [stainless .Target (targetName )] = stainlessviews.DownloadStatus {
116+ Status : "not started" ,
117+ Path : targetConfig .OutputPath ,
126118 }
127119 }
128120 cmds = append (cmds , m .updateView ("header" ))
@@ -153,8 +145,8 @@ func (m BuildModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
153145 }
154146 status , _ , conclusion := buildTarget .StepInfo ("commit" )
155147 if status == "completed" && conclusion != "fatal" {
156- if download , ok := m .downloads [target ]; ok && download .status == "not started" {
157- download .status = "started"
148+ if download , ok := m .downloads [target ]; ok && download .Status == "not started" {
149+ download .Status = "started"
158150 cmds = append (cmds , m .downloadTarget (target ))
159151 m .downloads [target ] = download
160152 }
@@ -218,7 +210,7 @@ func (m BuildModel) downloadTarget(target stainless.Target) tea.Cmd {
218210 if err != nil {
219211 return errorMsg (err )
220212 }
221- err = pullOutput (outputRes .Output , outputRes .URL , outputRes .Ref , m .downloads [target ].path , & Group {silent : true })
213+ err = pullOutput (outputRes .Output , outputRes .URL , outputRes .Ref , m .downloads [target ].Path , & Group {silent : true })
222214 if err != nil {
223215 return errorMsg (err )
224216 }
0 commit comments