diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/update.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cmd/update.go b/cmd/update.go new file mode 100644 index 0000000..c1aaec3 --- /dev/null +++ b/cmd/update.go @@ -0,0 +1,33 @@ +package cmd + +import ( + "fmt" + "os" + "os/exec" + + "github.com/spf13/cobra" +) + +var updateCmd = &cobra.Command{ + Use: "update", + Short: "Update dborg to the latest version", + Long: `Update dborg by running go install git.db.org.ai/dborg`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("Updating dborg...") + + installCmd := exec.Command("go", "install", "git.db.org.ai/dborg") + installCmd.Stdout = os.Stdout + installCmd.Stderr = os.Stderr + + if err := installCmd.Run(); err != nil { + fmt.Fprintf(os.Stderr, "Failed to update dborg: %v\n", err) + os.Exit(1) + } + + fmt.Println("dborg updated successfully!") + }, +} + +func init() { + rootCmd.AddCommand(updateCmd) +} |
