()
| 114 | } |
| 115 | |
| 116 | func (p *plugin) updateCmd() *cobra.Command { |
| 117 | var withBackup bool |
| 118 | |
| 119 | command := &cobra.Command{ |
| 120 | Use: "update", |
| 121 | Short: "Automatically updates the current app executable with the latest available version", |
| 122 | SilenceUsage: true, |
| 123 | RunE: func(command *cobra.Command, args []string) error { |
| 124 | var needConfirm bool |
| 125 | if isMaybeRunningInDocker() { |
| 126 | needConfirm = true |
| 127 | color.Yellow("NB! It seems that you are in a Docker container.") |
| 128 | color.Yellow("The update command may not work as expected in this context because usually the version of the app is managed by the container image itself.") |
| 129 | } else if isMaybeRunningInNixOS() { |
| 130 | needConfirm = true |
| 131 | color.Yellow("NB! It seems that you are in a NixOS.") |
| 132 | color.Yellow("Due to the non-standard filesystem implementation of the environment, the update command may not work as expected.") |
| 133 | } |
| 134 | |
| 135 | if needConfirm { |
| 136 | confirm := osutils.YesNoPrompt("Do you want to proceed with the update?", false) |
| 137 | if !confirm { |
| 138 | fmt.Println("The command has been cancelled.") |
| 139 | return nil |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | return p.update(withBackup) |
| 144 | }, |
| 145 | } |
| 146 | |
| 147 | command.PersistentFlags().BoolVar( |
| 148 | &withBackup, |
| 149 | "backup", |
| 150 | true, |
| 151 | "Creates a pb_data backup at the end of the update process", |
| 152 | ) |
| 153 | |
| 154 | return command |
| 155 | } |
| 156 | |
| 157 | func (p *plugin) update(withBackup bool) error { |
| 158 | color.Yellow("Fetching release information...") |
no test coverage detected