NewCmdUpdate creates the update command.
(f *cmdutil.Factory)
| 94 | |
| 95 | // NewCmdUpdate creates the update command. |
| 96 | func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command { |
| 97 | opts := &UpdateOptions{Factory: f} |
| 98 | |
| 99 | cmd := &cobra.Command{ |
| 100 | Use: "update", |
| 101 | Short: "Update lark-cli to the latest version", |
| 102 | Long: `Update lark-cli to the latest version. |
| 103 | |
| 104 | Detects the installation method automatically: |
| 105 | - npm install: runs npm install -g @larksuite/cli@<version> |
| 106 | - manual/other: shows GitHub Releases download URL |
| 107 | |
| 108 | Use --json for structured output (for AI agents and scripts). |
| 109 | Use --check to only check for updates without installing.`, |
| 110 | RunE: func(cmd *cobra.Command, args []string) error { |
| 111 | return updateRun(opts) |
| 112 | }, |
| 113 | } |
| 114 | cmdutil.DisableAuthCheck(cmd) |
| 115 | cmd.Flags().BoolVar(&opts.JSON, "json", false, "structured JSON output") |
| 116 | cmd.Flags().BoolVar(&opts.Force, "force", false, "force reinstall even if already up to date") |
| 117 | cmd.Flags().BoolVar(&opts.Check, "check", false, "only check for updates, do not install") |
| 118 | cmdutil.SetRisk(cmd, "high-risk-write") |
| 119 | |
| 120 | return cmd |
| 121 | } |
| 122 | |
| 123 | func updateRun(opts *UpdateOptions) error { |
| 124 | io := opts.Factory.IOStreams |