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

Function NewSelectCmd

pkg/cmd/application/selectapp/select.go:29–70  ·  view source on GitHub ↗
(f *cmdutil.Factory)

Source from the content-addressed store, hash-verified

27}
28
29func NewSelectCmd(f *cmdutil.Factory) *cobra.Command {
30 opts := &SelectOptions{
31 IO: f.IOStreams,
32 Config: f.Config,
33 NewDashboardClient: func(clientID string) *dashboard.Client {
34 return dashboard.NewClient(clientID)
35 },
36 }
37
38 cmd := &cobra.Command{
39 Use: "select",
40 Short: "Select an application to use as the active profile",
41 Long: heredoc.Doc(`
42 Select an Algolia application to use as the default CLI profile.
43 Fetches your applications from the API and lets you pick one.
44
45 If the selected application already has a local profile, it is set
46 as the default. Otherwise, a new profile is created and set as default.
47 `),
48 Example: heredoc.Doc(`
49 # Select interactively
50 $ algolia application select
51
52 # Select by name (non-interactive)
53 $ algolia application select --app-name "My App"
54 `),
55 Aliases: []string{"use"},
56 Args: validators.NoArgs(),
57 Annotations: map[string]string{
58 "skipAuthCheck": "true",
59 },
60 RunE: func(cmd *cobra.Command, args []string) error {
61 _, err := runSelectCmd(opts)
62 return err
63 },
64 }
65
66 cmd.Flags().
67 StringVar(&opts.AppName, "app-name", "", "Select application by name (non-interactive)")
68
69 return cmd
70}
71
72// Run executes the interactive application-selection flow and returns the
73// chosen application. Other commands (e.g. open) use it to ensure an

Callers 1

NewApplicationCmdFunction · 0.92

Calls 3

NewClientFunction · 0.92
NoArgsFunction · 0.92
runSelectCmdFunction · 0.85

Tested by

no test coverage detected