filebrowser/backend/cmd/users_export.go

27 lines
672 B
Go
Raw Normal View History

package cmd
import (
2024-10-07 22:44:53 +00:00
"github.com/gtsteffaniak/filebrowser/storage"
"github.com/gtsteffaniak/filebrowser/utils"
"github.com/spf13/cobra"
)
func init() {
usersCmd.AddCommand(usersExportCmd)
}
var usersExportCmd = &cobra.Command{
Use: "export <path>",
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,
2024-10-07 22:44:53 +00:00
Run: cobraCmd(func(cmd *cobra.Command, args []string, store *storage.Storage) {
list, err := store.Users.Gets("")
utils.CheckErr("store.Users.Gets", err)
err = marshal(args[0], list)
2024-10-07 22:44:53 +00:00
utils.CheckErr("marshal", err)
}),
}