all repos — weimar @ 28e896519b8b6466fbb9a904b18002993c823f76

Unnamed repository; edit this file 'description' to name the repository.

cmd/weimar/users.go (view raw)

 1package main
 2
 3import (
 4	"fmt"
 5
 6	"github.com/mjensen/weimar/internal/config"
 7	"github.com/spf13/cobra"
 8)
 9
10var usersCmd = &cobra.Command{
11	Use:   "users",
12	Short: "Manage users",
13}
14
15var usersListCmd = &cobra.Command{
16	Use:   "list",
17	Short: "List all users",
18	RunE: func(cmd *cobra.Command, args []string) error {
19		cfg := config.FromViper()
20		fmt.Fprintln(cmd.ErrOrStderr(), "users list (config path:", cfg.Database.Path, ")")
21		fmt.Fprintln(cmd.OutOrStdout(), "not yet implemented")
22		return nil
23	},
24}
25
26var usersCreateCmd = &cobra.Command{
27	Use:   "create <username> <password>",
28	Short: "Create a new user",
29	Args:  cobra.ExactArgs(2),
30	RunE: func(cmd *cobra.Command, args []string) error {
31		cfg := config.FromViper()
32		fmt.Fprintln(cmd.ErrOrStderr(), "users create (config path:", cfg.Database.Path, ")")
33		fmt.Fprintln(cmd.OutOrStdout(), "not yet implemented")
34		return nil
35	},
36}
37
38var usersDeleteCmd = &cobra.Command{
39	Use:   "delete <username>",
40	Short: "Delete a user",
41	Args:  cobra.ExactArgs(1),
42	RunE: func(cmd *cobra.Command, args []string) error {
43		fmt.Fprintln(cmd.OutOrStdout(), "not yet implemented")
44		return nil
45	},
46}
47
48var usersPasswordResetCmd = &cobra.Command{
49	Use:   "password-reset <username>",
50	Short: "Reset a user's password",
51	Args:  cobra.ExactArgs(1),
52	RunE: func(cmd *cobra.Command, args []string) error {
53		fmt.Fprintln(cmd.OutOrStdout(), "not yet implemented")
54		return nil
55	},
56}
57
58func init() {
59	rootCmd.AddCommand(usersCmd)
60	usersCmd.AddCommand(usersListCmd)
61	usersCmd.AddCommand(usersCreateCmd)
62	usersCmd.AddCommand(usersDeleteCmd)
63	usersCmd.AddCommand(usersPasswordResetCmd)
64}