Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/cmd/version.go
1541 views
1
/*
2
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
3
*/
4
package cmd
5
6
import (
7
"fmt"
8
"os"
9
"runtime"
10
11
"github.com/alist-org/alist/v3/internal/conf"
12
"github.com/spf13/cobra"
13
)
14
15
// VersionCmd represents the version command
16
var VersionCmd = &cobra.Command{
17
Use: "version",
18
Short: "Show current version of AList",
19
Run: func(cmd *cobra.Command, args []string) {
20
goVersion := fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
21
22
fmt.Printf(`Built At: %s
23
Go Version: %s
24
Author: %s
25
Commit ID: %s
26
Version: %s
27
WebVersion: %s
28
`, conf.BuiltAt, goVersion, conf.GitAuthor, conf.GitCommit, conf.Version, conf.WebVersion)
29
os.Exit(0)
30
},
31
}
32
33
func init() {
34
RootCmd.AddCommand(VersionCmd)
35
36
// Here you will define your flags and configuration settings.
37
38
// Cobra supports Persistent Flags which will work for this command
39
// and all subcommands, e.g.:
40
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")
41
42
// Cobra supports local flags which will only run when this command
43
// is called directly, e.g.:
44
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
45
}
46
47