alist/cmd/version.go

46 lines
1.1 KiB
Go
Raw Normal View History

2022-08-07 05:09:59 +00:00
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
"fmt"
"os"
"runtime"
2022-08-07 05:09:59 +00:00
2022-08-07 05:23:15 +00:00
"github.com/alist-org/alist/v3/internal/conf"
2022-08-07 05:09:59 +00:00
"github.com/spf13/cobra"
)
2022-12-18 11:53:39 +00:00
// VersionCmd represents the version command
var VersionCmd = &cobra.Command{
2022-08-07 05:09:59 +00:00
Use: "version",
Short: "Show current version of AList",
Run: func(cmd *cobra.Command, args []string) {
goVersion := fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
2022-08-07 05:09:59 +00:00
fmt.Printf(`Built At: %s
Go Version: %s
Author: %s
Commit ID: %s
Version: %s
WebVersion: %s
`, conf.BuiltAt, goVersion, conf.GitAuthor, conf.GitCommit, conf.Version, conf.WebVersion)
2022-08-07 05:09:59 +00:00
os.Exit(0)
},
}
func init() {
2022-12-18 11:53:39 +00:00
RootCmd.AddCommand(VersionCmd)
2022-08-07 05:09:59 +00:00
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}