Files
SaveAny-Bot/cmd/version.go
Krau 900823cdb9 refactor: refactor task logic for better scalability (#76)
* refactor: a big refactor. wip

* refactor: port handle file

* refactor: place all handlers

* fix: task info nil pointer

* feat: enhance task progress tracking and context management

* feat: cancel task

* feat: stream mode

* feat: silent mode

* feat: dir cmd

* refactor: remove unused old file

* feat: rule cmd

* feat: handle silent mode

* feat: batch task

* fix: batch task progress and temp file cleanup

* refactor: update file creation and cleanup methods for better resource management

* feat: add save command with silent mode handling

* feat: message link

* feat: update message prompts to include file count in storage selection

* feat: slient save links

* refactor: reduce dup code

* feat: rule type

* feat: chose dir

* feat: refactor file handling and storage rules, improve error handling and logging

* feat: rule mode

* feat: telegraph pics

* fix: tphpics nil pointer and inaccurate dirpath

* feat: silent save telegraph

* feat: add suffix to avoid file overwrite

* feat: new storage telegram

* chore: tidy go mod
2025-06-15 23:57:49 +08:00

47 lines
1.2 KiB
Go

package cmd
import (
"fmt"
"runtime"
"github.com/krau/SaveAny-Bot/pkg/consts"
"github.com/rhysd/go-github-selfupdate/selfupdate"
"github.com/blang/semver"
"github.com/spf13/cobra"
)
var VersionCmd = &cobra.Command{
Use: "version",
Aliases: []string{"v"},
Short: "Print the version number of saveany-bot",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("saveany-bot version: %s %s/%s\nBuildTime: %s, Commit: %s\n", consts.Version, runtime.GOOS, runtime.GOARCH, consts.BuildTime, consts.GitCommit)
},
}
var upgradeCmd = &cobra.Command{
Use: "upgrade",
Aliases: []string{"up"},
Short: "Upgrade saveany-bot to the latest version",
Run: func(cmd *cobra.Command, args []string) {
v := semver.MustParse(consts.Version)
latest, err := selfupdate.UpdateSelf(v, "krau/SaveAny-Bot")
if err != nil {
fmt.Println("Binary update failed:", err)
return
}
if latest.Version.Equals(v) {
fmt.Println("Current binary is the latest version", consts.Version)
} else {
fmt.Println("Successfully updated to version", latest.Version)
fmt.Println("Release note:\n", latest.ReleaseNotes)
}
},
}
func init() {
rootCmd.AddCommand(VersionCmd)
rootCmd.AddCommand(upgradeCmd)
}