feat: remove version cmd (#675)

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
Former-commit-id: 04a60c58f20d63ca7b25731c41e144bcf0f538cc [formerly e6e179799b64779515051df53352df5e63edc259] [formerly 0689eba81ff5f7ee3ea75db37b91cef4d6d8f35c [formerly 85899acae6edc445506384a5fa2c972131cb06e6]]
Former-commit-id: 96ca0cadb94131ddd3b57f0f11ad629edf687e40 [formerly 50130c75d39e67b15a645e7f4879acf34a5d6620]
Former-commit-id: 53b8120673a82217c3625de161d4ec57a96e1470
This commit is contained in:
Henrique Dias 2019-02-15 12:54:44 +01:00 committed by GitHub
parent 4cf1f2f6b4
commit 1259fc1bbc
8 changed files with 24 additions and 44 deletions

View File

@ -11,11 +11,10 @@ func init() {
} }
var cmdsCmd = &cobra.Command{ var cmdsCmd = &cobra.Command{
Use: "cmds", Use: "cmds",
Version: rootCmd.Version, Short: "Command runner management utility",
Short: "Command runner management utility", Long: `Command runner management utility.`,
Long: `Command runner management utility.`, Args: cobra.NoArgs,
Args: cobra.NoArgs,
} }
func printEvents(m map[string][]string) { func printEvents(m map[string][]string) {

View File

@ -20,11 +20,10 @@ func init() {
} }
var configCmd = &cobra.Command{ var configCmd = &cobra.Command{
Use: "config", Use: "config",
Version: rootCmd.Version, Short: "Configuration management utility",
Short: "Configuration management utility", Long: `Configuration management utility.`,
Long: `Configuration management utility.`, Args: cobra.NoArgs,
Args: cobra.NoArgs,
} }
func addConfigFlags(flags *pflag.FlagSet) { func addConfigFlags(flags *pflag.FlagSet) {

View File

@ -12,11 +12,10 @@ func init() {
} }
var hashCmd = &cobra.Command{ var hashCmd = &cobra.Command{
Use: "hash <password>", Use: "hash <password>",
Version: rootCmd.Version, Short: "Hashes a password",
Short: "Hashes a password", Long: `Hashes a password using bcrypt algorithm.`,
Long: `Hashes a password using bcrypt algorithm.`, Args: cobra.ExactArgs(1),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
pwd, err := users.HashPwd(args[0]) pwd, err := users.HashPwd(args[0])
checkErr(err) checkErr(err)

View File

@ -15,7 +15,6 @@ import (
"github.com/filebrowser/filebrowser/v2/settings" "github.com/filebrowser/filebrowser/v2/settings"
"github.com/filebrowser/filebrowser/v2/storage" "github.com/filebrowser/filebrowser/v2/storage"
"github.com/filebrowser/filebrowser/v2/users" "github.com/filebrowser/filebrowser/v2/users"
"github.com/filebrowser/filebrowser/v2/version"
homedir "github.com/mitchellh/go-homedir" homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -55,9 +54,8 @@ func addServerFlags(flags *pflag.FlagSet) {
} }
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "filebrowser", Use: "filebrowser",
Version: version.Version, Short: "A stylish web-based file browser",
Short: "A stylish web-based file browser",
Long: `File Browser CLI lets you create the database to use with File Browser, Long: `File Browser CLI lets you create the database to use with File Browser,
manage your users and all the configurations without acessing the manage your users and all the configurations without acessing the
web interface. web interface.

View File

@ -19,7 +19,6 @@ func init() {
var rulesCmd = &cobra.Command{ var rulesCmd = &cobra.Command{
Use: "rules", Use: "rules",
Version: rootCmd.Version,
Short: "Rules management utility", Short: "Rules management utility",
Long: `On each subcommand you'll have available at least two flags: Long: `On each subcommand you'll have available at least two flags:
"username" and "id". You must either set only one of them "username" and "id". You must either set only one of them

View File

@ -14,9 +14,8 @@ func init() {
} }
var upgradeCmd = &cobra.Command{ var upgradeCmd = &cobra.Command{
Use: "upgrade", Use: "upgrade",
Version: rootCmd.Version, Short: "Upgrades an old configuration",
Short: "Upgrades an old configuration",
Long: `Upgrades an old configuration. This command DOES NOT Long: `Upgrades an old configuration. This command DOES NOT
import share links because they are incompatible with import share links because they are incompatible with
this version.`, this version.`,

View File

@ -18,11 +18,10 @@ func init() {
} }
var usersCmd = &cobra.Command{ var usersCmd = &cobra.Command{
Use: "users", Use: "users",
Version: rootCmd.Version, Short: "Users management utility",
Short: "Users management utility", Long: `Users management utility.`,
Long: `Users management utility.`, Args: cobra.NoArgs,
Args: cobra.NoArgs,
} }
func printUsers(users []*users.User) { func printUsers(users []*users.User) {

View File

@ -1,32 +1,20 @@
package cmd package cmd
import ( import (
"text/template" "fmt"
"github.com/filebrowser/filebrowser/v2/version"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
func init() { func init() {
rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(versionCmd)
cmdsCmd.AddCommand(versionCmd)
configCmd.AddCommand(versionCmd)
hashCmd.AddCommand(versionCmd)
upgradeCmd.AddCommand(versionCmd)
rulesCmd.AddCommand(versionCmd)
usersCmd.AddCommand(versionCmd)
} }
var versionCmd = &cobra.Command{ var versionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Print the version number of File Browser", Short: "Print the version number",
Long: `All software has versions. This is File Browser's`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
// https://github.com/spf13/cobra/issues/724 fmt.Println("File Browser Version " + version.Version)
t := template.New("version")
template.Must(t.Parse(rootCmd.VersionTemplate()))
err := t.Execute(rootCmd.OutOrStdout(), rootCmd)
if err != nil {
rootCmd.Println(err)
}
}, },
} }