This repository has no description
1package main
2
3import (
4 "context"
5 "log/slog"
6 "os"
7
8 "github.com/urfave/cli/v3"
9 tlog "tangled.org/core/log"
10 "tangled.org/core/spindle"
11)
12
13func main() {
14 cmd := &cli.Command{
15 Name: "spindle",
16 Usage: "spindle continuous integration runner",
17 Commands: []*cli.Command{
18 Run(),
19 adminCmd,
20 },
21 DefaultCommand: "run",
22 }
23
24 logger := tlog.New("spindle")
25 slog.SetDefault(logger)
26
27 ctx := context.Background()
28 ctx = tlog.IntoContext(ctx, logger)
29
30 if err := cmd.Run(ctx, os.Args); err != nil {
31 logger.Error(err.Error())
32 os.Exit(-1)
33 }
34}
35
36func Run() *cli.Command {
37 return &cli.Command{
38 Name: "run",
39 Usage: "run the spindle server",
40 Action: func(ctx context.Context, cmd *cli.Command) error {
41 return spindle.Run(ctx)
42 },
43 }
44}
45
46var adminCmd = &cli.Command{
47 Name: "admin",
48 Flags: []cli.Flag{
49 &cli.StringFlag{
50 Name: "url",
51 Value: "http://localhost:6555",
52 Usage: "spindle server url",
53 },
54 &cli.StringFlag{
55 Name: "password",
56 Usage: "admin password",
57 Sources: cli.EnvVars("SPINDLE_SERVER_ADMIN_PASSWORD"),
58 },
59 },
60 Commands: []*cli.Command{
61 {
62 Name: "allow",
63 Usage: "allow a did to use this spindle",
64 ArgsUsage: "<did>",
65 Action: func(ctx context.Context, c *cli.Command) error {
66 return spindle.AdminAllowMember(ctx, c.String("url"), c.String("password"), c.Args().First())
67 },
68 },
69 {
70 Name: "block",
71 Usage: "block a did from using this spindle",
72 ArgsUsage: "<did>",
73 Action: func(ctx context.Context, c *cli.Command) error {
74 return spindle.AdminBlockMember(ctx, c.String("url"), c.String("password"), c.Args().First())
75 },
76 },
77 },
78}