(deps commandDeps)
| 49 | } |
| 50 | |
| 51 | func newUpdateCommand(deps commandDeps) *cobra.Command { |
| 52 | var checkOnly bool |
| 53 | |
| 54 | cmd := &cobra.Command{ |
| 55 | Use: updateUpdateKey, |
| 56 | Short: "Check for and apply the latest stable AGH release", |
| 57 | Long: strings.TrimSpace(` |
| 58 | Check GitHub Releases for the latest stable AGH build and apply it when this install supports |
| 59 | self-update. Managed installs return the exact package-manager upgrade path instead of mutating |
| 60 | files directly. |
| 61 | `), |
| 62 | Example: strings.TrimSpace(` |
| 63 | agh update |
| 64 | agh update --check |
| 65 | agh update -o json |
| 66 | `), |
| 67 | Args: cobra.NoArgs, |
| 68 | RunE: func(cmd *cobra.Command, _ []string) error { |
| 69 | return runUpdateCommand(cmd, deps, checkOnly) |
| 70 | }, |
| 71 | } |
| 72 | |
| 73 | cmd.Flags().BoolVar(&checkOnly, "check", false, "Check for a newer stable release without changing files") |
| 74 | return cmd |
| 75 | } |
| 76 | |
| 77 | func runUpdateCommand(cmd *cobra.Command, deps commandDeps, checkOnly bool) error { |
| 78 | manager, err := resolveUpdateManager(deps) |
no test coverage detected