From 2ba5a4275af280b5e4ecd7324a0226af4371f7ab Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 8 Jan 2019 16:09:25 +0000 Subject: [PATCH] docs: improve some cli docs License: MIT Signed-off-by: Henrique Dias --- cmd/config_export.go | 3 ++- cmd/config_import.go | 3 ++- cmd/root.go | 1 + cmd/users_export.go | 6 ++++-- cmd/users_import.go | 9 +++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/config_export.go b/cmd/config_export.go index 80574b29..e57f0675 100644 --- a/cmd/config_export.go +++ b/cmd/config_export.go @@ -10,7 +10,8 @@ func init() { var configExportCmd = &cobra.Command{ Use: "export ", - Short: "Export the configuration to a file.", + Short: "Export the configuration to a file", + Long: "Export the configuration to a file.", Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { settings, err := d.store.Settings.Get() diff --git a/cmd/config_import.go b/cmd/config_import.go index 3463c2f8..5c6b9ed8 100644 --- a/cmd/config_import.go +++ b/cmd/config_import.go @@ -23,7 +23,8 @@ type settingsFile struct { var configImportCmd = &cobra.Command{ Use: "import ", - Short: `Import a configuration file. This will replace all the existing + 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 diff --git a/cmd/root.go b/cmd/root.go index 7e6915cb..fd64b771 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -119,6 +119,7 @@ The precedence of the configuration values are as follows: - flag - environment variable - configuration file +- database values - defaults The environment variables are prefixed by "FB_" followed by the option diff --git a/cmd/users_export.go b/cmd/users_export.go index 711cd420..d7590592 100644 --- a/cmd/users_export.go +++ b/cmd/users_export.go @@ -10,8 +10,10 @@ func init() { var usersExportCmd = &cobra.Command{ Use: "export ", - Short: "Export all users.", - Args: jsonYamlArg, + 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.`, + Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { list, err := d.store.Users.Gets("") checkErr(err) diff --git a/cmd/users_import.go b/cmd/users_import.go index 67f32f75..2c8161f2 100644 --- a/cmd/users_import.go +++ b/cmd/users_import.go @@ -17,7 +17,8 @@ func init() { var usersImportCmd = &cobra.Command{ Use: "import ", - Short: "Import users from a file.", + Short: "Import users from a file", + Long: "Import users from a file.", Args: jsonYamlArg, Run: python(func(cmd *cobra.Command, args []string, d pythonData) { fd, err := os.Open(args[0]) @@ -36,16 +37,16 @@ var usersImportCmd = &cobra.Command{ if mustGetBool(cmd.Flags(), "replace") { oldUsers, err := d.store.Users.Gets("") checkErr(err) - + err = marshal("users.backup.json", list) checkErr(err) - + for _, user := range oldUsers { err = d.store.Users.Delete(user.ID) checkErr(err) } } - + overwrite := mustGetBool(cmd.Flags(), "overwrite") for _, user := range list {