MCPcopy Create free account
hub / github.com/algolia/cli / openDashboardTarget

Function openDashboardTarget

pkg/cmd/open/open.go:313–338  ·  view source on GitHub ↗

openDashboardTarget signs the user in, resolves the current application (selecting one if needed), then opens the dashboard page.

(opts *OpenOptions, target dashboardTarget)

Source from the content-addressed store, hash-verified

311// openDashboardTarget signs the user in, resolves the current application
312// (selecting one if needed), then opens the dashboard page.
313func openDashboardTarget(opts *OpenOptions, target dashboardTarget) error {
314 client := opts.NewDashboardClient(auth.OAuthClientID())
315 accessToken, err := opts.Authenticate(opts.IO, client)
316 if err != nil {
317 return err
318 }
319
320 appID, err := opts.resolveApplicationForAccount(client, accessToken)
321 if err != nil {
322 return err
323 }
324 if appID == "" {
325 // No application is available to scope to; the selection flow has
326 // already explained the situation to the user.
327 return nil
328 }
329
330 // The base URL is resolved from ALGOLIA_DASHBOARD_URL by the dashboard
331 // client (falling back to its compiled-in default).
332 url := dashboardURL(client.DashboardURL, appID, target)
333
334 cs := opts.IO.ColorScheme()
335 fmt.Fprintf(opts.IO.Out, "Opening %s\n", cs.Bold(url))
336
337 return opts.Browser(url)
338}
339
340func applicationInAccount(apps []dashboard.Application, appID string) bool {
341 for _, app := range apps {

Callers 1

runOpenCmdFunction · 0.85

Calls 5

OAuthClientIDFunction · 0.92
dashboardURLFunction · 0.85
ColorSchemeMethod · 0.80
BoldMethod · 0.80

Tested by

no test coverage detected