feat: export to file instead
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
parent
7beb0cde18
commit
f0c19e89e6
@ -12,14 +12,18 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var usersExportCmd = &cobra.Command{
|
var usersExportCmd = &cobra.Command{
|
||||||
Use: "export",
|
Use: "export <filename>",
|
||||||
Short: "Export all users.",
|
Short: "Export all users.",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.ExactArgs(1),
|
||||||
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
|
||||||
list, err := d.store.Users.Gets("")
|
list, err := d.store.Users.Gets("")
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|
||||||
encoder := json.NewEncoder(os.Stdout)
|
fd, err := os.Create(args[0])
|
||||||
|
checkErr(err)
|
||||||
|
defer fd.Close()
|
||||||
|
|
||||||
|
encoder := json.NewEncoder(fd)
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
encoder.Encode(list)
|
encoder.Encode(list)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user