-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
68 lines (65 loc) · 1.55 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"github.com/simonwep/genesis/commands"
"github.com/simonwep/genesis/core"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
"os"
)
func main() {
app := &cli.App{
Name: "genesis",
Usage: "A tiny server for all your json needs",
Authors: []*cli.Author{
{Name: "Simon Reinisch", Email: "[email protected]"},
},
Commands: []*cli.Command{
{
Name: "start",
Usage: "Start the server",
Action: commands.Start,
},
{
Name: "users",
Usage: "Manage users",
Subcommands: []*cli.Command{
{
Name: "ls",
Aliases: []string{"list"},
Usage: "Lists all users",
UsageText: "genesis user ls",
Action: commands.ListUsers,
},
{
Name: "rm",
Aliases: []string{"remove"},
Usage: "Removes a user",
UsageText: "genesis user rm [username]",
Action: commands.RemoveUser,
},
{
Name: "add",
Usage: "Adds a user, add ! at the end of the username to make the user an admin",
UsageText: "genesis user add [username] [password]",
Action: commands.AddUser,
},
{
Name: "update",
Usage: "Updates a user",
UsageText: "genesis user update [flags] [username]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "password",
Usage: "Sets a new password",
},
},
Action: commands.UpdateUser,
},
},
},
},
}
if err := app.Run(os.Args); err != nil {
core.Logger.Fatal("failed to run command", zap.Error(err))
}
}