2019-01-05 22:44:33 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2019-01-06 21:34:56 +00:00
|
|
|
"text/template"
|
2019-01-05 22:44:33 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(versionCmd)
|
2019-01-06 21:34:56 +00:00
|
|
|
cmdsCmd.AddCommand(versionCmd)
|
|
|
|
configCmd.AddCommand(versionCmd)
|
|
|
|
hashCmd.AddCommand(versionCmd)
|
|
|
|
upgradeCmd.AddCommand(versionCmd)
|
|
|
|
rulesCmd.AddCommand(versionCmd)
|
|
|
|
usersCmd.AddCommand(versionCmd)
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var versionCmd = &cobra.Command{
|
|
|
|
Use: "version",
|
2019-01-06 21:34:56 +00:00
|
|
|
Short: "Print the version number of File Browser",
|
|
|
|
Long: `All software has versions. This is File Browser's`,
|
2019-01-05 22:44:33 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2019-01-06 21:34:56 +00:00
|
|
|
// https://github.com/spf13/cobra/issues/724
|
|
|
|
t := template.New("version")
|
|
|
|
template.Must(t.Parse(rootCmd.VersionTemplate()))
|
|
|
|
err := t.Execute(rootCmd.OutOrStdout(), rootCmd)
|
|
|
|
if err != nil {
|
|
|
|
rootCmd.Println(err)
|
|
|
|
}
|
2019-01-05 22:44:33 +00:00
|
|
|
},
|
|
|
|
}
|