(ctx context.Context, cfg *cli.Config, drv *ui.Driver, orgAPID, realmAPID string)
| 288 | } |
| 289 | |
| 290 | func (c *Setup) serviceAPID(ctx context.Context, cfg *cli.Config, drv *ui.Driver, orgAPID, realmAPID string) (string, error) { |
| 291 | if c.ServiceAPID != "" { |
| 292 | return c.ServiceAPID, nil |
| 293 | } |
| 294 | |
| 295 | if cfg.Service.APID != "" { |
| 296 | drv.Activate(ctx, &componentmodels.ConfigVia{ |
| 297 | Config: cfg, |
| 298 | ConfigFetchFn: func(cfg *cli.Config) any { return cfg.Service.APID }, |
| 299 | Flag: "--service", |
| 300 | Singular: "service", |
| 301 | }) |
| 302 | return cfg.Service.APID, nil |
| 303 | } |
| 304 | |
| 305 | selector := &component.Selector[api.Service]{ |
| 306 | Prompt: fmt.Sprintf("Which %s/%s service's lcl.host local development environment do you want to setup?", ui.Emphasize(orgAPID), ui.Emphasize(realmAPID)), |
| 307 | Flag: "--service", |
| 308 | |
| 309 | Creatable: true, |
| 310 | |
| 311 | Fetcher: &component.Fetcher[api.Service]{ |
| 312 | FetchFn: func() ([]api.Service, error) { return c.anc.GetOrgServices(ctx, orgAPID, api.NonDiagnosticServices) }, |
| 313 | }, |
| 314 | } |
| 315 | |
| 316 | service, err := selector.Choice(ctx, drv) |
| 317 | if err != nil { |
| 318 | return "", err |
| 319 | } |
| 320 | if service == nil || (*service == api.Service{}) { |
| 321 | return "", nil |
| 322 | } |
| 323 | return service.Slug, nil |
| 324 | } |
| 325 | |
| 326 | func (c *Setup) serviceName(ctx context.Context, cfg *cli.Config, drv *ui.Driver) (string, error) { |
| 327 | if cfg.Service.Name != "" { |
no test coverage detected