@@ -42,15 +42,17 @@ type ProjectOrgsLister interface {
4242}
4343
4444type DefaultSetterOpts struct {
45- Service string
46- OpsManagerURL string
47- ProjectID string
48- OrgID string
49- MongoShellPath string
50- TelemetryEnabled bool
51- Output string
52- Store ProjectOrgsLister
53- OutWriter io.Writer
45+ Service string
46+ OpsManagerURL string
47+ ProjectID string
48+ OrgID string
49+ MongoShellPath string
50+ TelemetryEnabled bool
51+ Output string
52+ Store ProjectOrgsLister
53+ OutWriter io.Writer
54+ AskedOrgsOrProjects bool
55+ OnMultipleOrgsOrProjects func ()
5456}
5557
5658func (opts * DefaultSetterOpts ) InitStore (ctx context.Context ) error {
@@ -174,6 +176,7 @@ func (opts *DefaultSetterOpts) AskProject() error {
174176 if err2 := telemetry .TrackAskOne (p , & manually ); err2 != nil {
175177 return err2
176178 }
179+ opts .AskedOrgsOrProjects = true
177180 if manually {
178181 p := prompt .NewProjectIDInput ()
179182 return telemetry .TrackAskOne (p , & opts .ProjectID , survey .WithValidator (validate .OptionalObjectID ))
@@ -182,17 +185,17 @@ func (opts *DefaultSetterOpts) AskProject() error {
182185 return nil
183186 }
184187
185- fmt .Println ("projects" , pSlice )
186-
187188 if len (pSlice ) == 1 {
188189 opts .ProjectID = pMap [pSlice [0 ]]
189190 } else {
191+ opts .runOnMultipleOrgsOrProjects ()
190192 p := prompt .NewProjectSelect (pSlice )
191193 var projectID string
192194 if err := telemetry .TrackAskOne (p , & projectID ); err != nil {
193195 return err
194196 }
195197 opts .ProjectID = pMap [projectID ]
198+ opts .AskedOrgsOrProjects = true
196199 }
197200
198201 return nil
@@ -230,6 +233,7 @@ func (opts *DefaultSetterOpts) AskOrg() error {
230233 if err2 := telemetry .TrackAskOne (p , & manually ); err2 != nil {
231234 return err2
232235 }
236+ opts .AskedOrgsOrProjects = true
233237 if manually {
234238 p := prompt .NewOrgIDInput ()
235239 return telemetry .TrackAskOne (p , & opts .OrgID , survey .WithValidator (validate .OptionalObjectID ))
@@ -241,12 +245,14 @@ func (opts *DefaultSetterOpts) AskOrg() error {
241245 if len (oSlice ) == 1 {
242246 opts .OrgID = oMap [oSlice [0 ]]
243247 } else {
248+ opts .runOnMultipleOrgsOrProjects ()
244249 p := prompt .NewOrgSelect (oSlice )
245250 var orgID string
246251 if err := telemetry .TrackAskOne (p , & orgID ); err != nil {
247252 return err
248253 }
249254 opts .OrgID = oMap [orgID ]
255+ opts .AskedOrgsOrProjects = true
250256 }
251257
252258 return nil
@@ -322,3 +328,9 @@ func (*DefaultSetterOpts) DefaultQuestions() []*survey.Question {
322328 }
323329 return q
324330}
331+
332+ func (opts * DefaultSetterOpts ) runOnMultipleOrgsOrProjects () {
333+ if opts .OnMultipleOrgsOrProjects != nil {
334+ opts .OnMultipleOrgsOrProjects ()
335+ }
336+ }
0 commit comments