MCPcopy Create free account
hub / github.com/compozy/agh / newOpenCommand

Function newOpenCommand

internal/cli/open.go:13–37  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

11)
12
13func newOpenCommand(deps commandDeps) *cobra.Command {
14 return &cobra.Command{
15 Use: "open",
16 Short: "Open the AGH web UI in the default browser",
17 RunE: func(cmd *cobra.Command, _ []string) error {
18 ctx := cmd.Context()
19
20 client, err := clientFromDeps(deps)
21 if err != nil {
22 return err
23 }
24
25 status, err := client.DaemonStatus(ctx)
26 if err != nil {
27 return fmt.Errorf("open: daemon is not running: %w", err)
28 }
29 if status.HTTPHost == "" || status.HTTPPort == 0 {
30 return errors.New("open: daemon did not report a valid HTTP address")
31 }
32
33 url := fmt.Sprintf("http://%s:%d", status.HTTPHost, status.HTTPPort)
34 return openBrowser(ctx, url)
35 },
36 }
37}
38
39func openBrowser(ctx context.Context, url string) error {
40 var cmd *exec.Cmd

Callers 1

newRootCommandFunction · 0.85

Calls 3

clientFromDepsFunction · 0.85
openBrowserFunction · 0.85
DaemonStatusMethod · 0.65

Tested by

no test coverage detected