()
| 21 | } |
| 22 | |
| 23 | func updateCmd() *cobra.Command { |
| 24 | flags := &updateCmdFlags{} |
| 25 | |
| 26 | command := &cobra.Command{ |
| 27 | Use: "update [pkg]...", |
| 28 | Short: "Update packages in your devbox", |
| 29 | Long: "Update one, many, or all packages in your devbox. " + |
| 30 | "If no packages are specified, all packages will be updated. " + |
| 31 | "Legacy non-versioned packages will be converted to @latest versioned " + |
| 32 | "packages resolved to their current version.", |
| 33 | PreRunE: func(cmd *cobra.Command, args []string) error { |
| 34 | if flags.noInstall { |
| 35 | return nil |
| 36 | } |
| 37 | return ensureNixInstalled(cmd, args) |
| 38 | }, |
| 39 | RunE: func(cmd *cobra.Command, args []string) error { |
| 40 | return updateCmdFunc(cmd, args, flags) |
| 41 | }, |
| 42 | } |
| 43 | |
| 44 | flags.config.register(command) |
| 45 | command.Flags().BoolVar( |
| 46 | &flags.sync, |
| 47 | "sync-lock", |
| 48 | false, |
| 49 | "sync all devbox.lock dependencies in multiple projects. "+ |
| 50 | "Dependencies will sync to the latest local version.", |
| 51 | ) |
| 52 | command.Flags().BoolVar( |
| 53 | &flags.allProjects, |
| 54 | "all-projects", |
| 55 | false, |
| 56 | "update all projects in the working directory, recursively.", |
| 57 | ) |
| 58 | command.Flags().BoolVar( |
| 59 | &flags.noInstall, |
| 60 | "no-install", |
| 61 | false, |
| 62 | "update lockfile but don't install anything", |
| 63 | ) |
| 64 | return command |
| 65 | } |
| 66 | |
| 67 | func updateCmdFunc(cmd *cobra.Command, args []string, flags *updateCmdFlags) error { |
| 68 | if len(args) > 0 && flags.sync { |
no test coverage detected