| 26 | } |
| 27 | |
| 28 | func NewUpdateCmd(f *cmdutil.Factory) *cobra.Command { |
| 29 | opts := &UpdateOptions{ |
| 30 | IO: f.IOStreams, |
| 31 | Config: f.Config, |
| 32 | PrintFlags: cmdutil.NewPrintFlags(), |
| 33 | NewDashboardClient: func(clientID string) *dashboard.Client { |
| 34 | return dashboard.NewClient(clientID) |
| 35 | }, |
| 36 | } |
| 37 | |
| 38 | cmd := &cobra.Command{ |
| 39 | Use: "update", |
| 40 | Short: "Rename the current Algolia application", |
| 41 | Long: heredoc.Doc(` |
| 42 | Rename the application associated with the current CLI profile. |
| 43 | Requires an active application to be selected (run "algolia application select" first). |
| 44 | `), |
| 45 | Example: heredoc.Doc(` |
| 46 | # Rename the current application |
| 47 | $ algolia application update --name "New Name" |
| 48 | `), |
| 49 | Args: validators.NoArgs(), |
| 50 | Annotations: map[string]string{ |
| 51 | "skipAuthCheck": "true", |
| 52 | }, |
| 53 | RunE: func(cmd *cobra.Command, args []string) error { |
| 54 | return runUpdateCmd(opts) |
| 55 | }, |
| 56 | } |
| 57 | |
| 58 | cmd.Flags().StringVar(&opts.Name, "name", "", "New name for the current application") |
| 59 | _ = cmd.MarkFlagRequired("name") |
| 60 | |
| 61 | opts.PrintFlags.AddFlags(cmd) |
| 62 | |
| 63 | return cmd |
| 64 | } |
| 65 | |
| 66 | func runUpdateCmd(opts *UpdateOptions) error { |
| 67 | cs := opts.IO.ColorScheme() |