feat: config and users export
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
cae8809da0
commit
2bcbf69b43
27
cmd/config_export.go
Normal file
27
cmd/config_export.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
configCmd.AddCommand(configExportCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
var configExportCmd = &cobra.Command{
|
||||||
|
Use: "export",
|
||||||
|
Short: "Export the config.",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
||||||
|
settings, err := d.store.Settings.Get()
|
||||||
|
checkErr(err)
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(os.Stdout)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
encoder.Encode(settings)
|
||||||
|
|
||||||
|
}, pythonConfig{}),
|
||||||
|
}
|
||||||
27
cmd/users_export.go
Normal file
27
cmd/users_export.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
usersCmd.AddCommand(usersExportCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
var usersExportCmd = &cobra.Command{
|
||||||
|
Use: "export",
|
||||||
|
Short: "Export all users.",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
||||||
|
list, err := d.store.Users.Gets("")
|
||||||
|
checkErr(err)
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(os.Stdout)
|
||||||
|
encoder.SetIndent("", " ")
|
||||||
|
encoder.Encode(list)
|
||||||
|
|
||||||
|
}, pythonConfig{}),
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user