From e1026a1fb4527c5ea92209160ac94c0362df78f9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 8 Jan 2019 16:37:02 +0000 Subject: [PATCH] feat: add docs info License: MIT Signed-off-by: Henrique Dias Former-commit-id: 4cc444f7168a76920c2821534027f121b7b0b0d5 [formerly fc1b399bbcf6cbd0a26db133ce644192664e4987] [formerly c71a14856c55345626eb7982e2bbe9ca0b7a1aec [formerly e68af011d47bebd47a4f49faeb029db573acd457]] Former-commit-id: b6ec8dd8817ec6bf028e1e7df299f8dd720628d9 [formerly 99077c4ca6faac93a1c956d96833faa3f2c40fe6] Former-commit-id: 620919fdfd9f213cc61e4ce3b4e8650096a489b4 --- cmd/cmds_rm.go | 10 +++++++++- cmd/config_export.go | 8 +++++--- cmd/config_import.go | 7 +++++-- cmd/config_init.go | 2 +- cmd/config_set.go | 2 +- cmd/docs.go | 2 +- cmd/rule_rm.go | 10 +++++++++- cmd/users_export.go | 2 +- cmd/users_import.go | 9 ++++++--- 9 files changed, 38 insertions(+), 14 deletions(-) diff --git a/cmd/cmds_rm.go b/cmd/cmds_rm.go index e0a32d39..2a863213 100644 --- a/cmd/cmds_rm.go +++ b/cmd/cmds_rm.go @@ -13,7 +13,15 @@ func init() { var cmdsRmCmd = &cobra.Command{ Use: "rm [index_end]", Short: "Removes a command from an event hooker", - Long: `Removes a command from an event hooker.`, + Long: `Removes a command from an event hooker. The provided index +is the same that's printed when you run 'cmds ls'. Note +that after each removal/addition, the index of the +commands change. So be careful when removing them after each +other. + +You can also specify an optional parameter (index_end) so +you can remove all commands from 'index' to 'index_end', +including 'index_end'.`, Args: func(cmd *cobra.Command, args []string) error { if err := cobra.RangeArgs(2, 3)(cmd, args); err != nil { return err diff --git a/cmd/config_export.go b/cmd/config_export.go index e57f0675..9d6450f9 100644 --- a/cmd/config_export.go +++ b/cmd/config_export.go @@ -9,10 +9,12 @@ func init() { } var configExportCmd = &cobra.Command{ - Use: "export ", + Use: "export ", Short: "Export the configuration to a file", - Long: "Export the configuration to a file.", - Args: jsonYamlArg, + Long: `Export the configuration to a file. The path must be for a +json or yaml file. This exported configuration can be changed, +and imported again with 'config import' command.`, + Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { settings, err := d.store.Settings.Get() checkErr(err) diff --git a/cmd/config_import.go b/cmd/config_import.go index 5c6b9ed8..7182da9a 100644 --- a/cmd/config_import.go +++ b/cmd/config_import.go @@ -22,13 +22,16 @@ type settingsFile struct { } var configImportCmd = &cobra.Command{ - Use: "import ", + Use: "import ", Short: "Import a configuration file", Long: `Import a configuration file. This will replace all the existing configuration. Can be used with or without unexisting databases. + If used with a nonexisting database, a key will be generated automatically. Otherwise the key will be kept the same as in the -database.`, +database. + +The path must be for a json or yaml file.`, Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { var key []byte diff --git a/cmd/config_init.go b/cmd/config_init.go index 86098376..f4794cb6 100644 --- a/cmd/config_init.go +++ b/cmd/config_init.go @@ -18,7 +18,7 @@ var configInitCmd = &cobra.Command{ Short: "Initialize a new database", Long: `Initialize a new database to use with File Browser. All of this options can be changed in the future with the command -"filebrowser config set". The user related flags apply +'filebrowser config set'. The user related flags apply to the defaults when creating new users and you don't override the options.`, Args: cobra.NoArgs, diff --git a/cmd/config_set.go b/cmd/config_set.go index 7ccf7e43..f725fd45 100644 --- a/cmd/config_set.go +++ b/cmd/config_set.go @@ -17,7 +17,7 @@ var configSetCmd = &cobra.Command{ Use: "set", Short: "Updates the configuration", Long: `Updates the configuration. Set the flags for the options -you want to change.`, +you want to change. Other options will remain unchanged.`, Args: cobra.NoArgs, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { flags := cmd.Flags() diff --git a/cmd/docs.go b/cmd/docs.go index 49f5f3f7..2e199b29 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -9,8 +9,8 @@ import ( "sort" "strings" - "github.com/spf13/pflag" "github.com/spf13/cobra" + "github.com/spf13/pflag" ) func init() { diff --git a/cmd/rule_rm.go b/cmd/rule_rm.go index 20e9d1e8..862eff51 100644 --- a/cmd/rule_rm.go +++ b/cmd/rule_rm.go @@ -17,7 +17,15 @@ func init() { var rulesRmCommand = &cobra.Command{ Use: "rm [index_end]", Short: "Remove a global rule or user rule", - Long: `Remove a global rule or user rule.`, + Long: `Remove a global rule or user rule. The provided index +is the same that's printed when you run 'rules ls'. Note +that after each removal/addition, the index of the +commands change. So be careful when removing them after each +other. + +You can also specify an optional parameter (index_end) so +you can remove all commands from 'index' to 'index_end', +including 'index_end'.`, Args: func(cmd *cobra.Command, args []string) error { if err := cobra.RangeArgs(1, 2)(cmd, args); err != nil { return err diff --git a/cmd/users_export.go b/cmd/users_export.go index d7590592..c0160f68 100644 --- a/cmd/users_export.go +++ b/cmd/users_export.go @@ -9,7 +9,7 @@ func init() { } var usersExportCmd = &cobra.Command{ - Use: "export ", + Use: "export ", Short: "Export all users to a file.", Long: `Export all users to a json or yaml file. Please indicate the path to the file where you want to write the users.`, diff --git a/cmd/users_import.go b/cmd/users_import.go index 2c8161f2..f1c873af 100644 --- a/cmd/users_import.go +++ b/cmd/users_import.go @@ -16,10 +16,13 @@ func init() { } var usersImportCmd = &cobra.Command{ - Use: "import ", + Use: "import ", Short: "Import users from a file", - Long: "Import users from a file.", - Args: jsonYamlArg, + Long: `Import users from a file. The path must be for a json or yaml +file. You can use this command to import new users to your +installation. For that, just don't place their ID on the files +list or set it to 0.`, + Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { fd, err := os.Open(args[0]) checkErr(err)