Stian Fredrik Aune
3 years ago
8 changed files with 140 additions and 5 deletions
-
16app/client/handler.go
-
32cmd/lucy/handlercmd.go
-
1cmd/lucy/help.go
-
15cmd/lucy/main.go
-
43cmd/lucy/tables.go
-
6go.sum
-
11install-lucy.sh
-
21models/eventhandler.go
@ -0,0 +1,16 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"context" |
|||
"git.aiterp.net/lucifer/new-server/models" |
|||
) |
|||
|
|||
func (client *Client) GetHandlers(ctx context.Context, fetchStr string) ([]models.EventHandler, error) { |
|||
handlers := make([]models.EventHandler, 0, 16) |
|||
err := client.Fetch(ctx, "GET", "/api/event-handlers", &handlers, nil) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
return handlers, nil |
|||
} |
@ -0,0 +1,32 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"context" |
|||
"fmt" |
|||
"git.aiterp.net/lucifer/new-server/app/client" |
|||
"log" |
|||
"os" |
|||
) |
|||
|
|||
func handlerCmd( |
|||
ctx context.Context, |
|||
c client.Client, |
|||
) { |
|||
cmd := parseCommand(os.Args[2:]) |
|||
|
|||
switch cmd.Name { |
|||
case "list": |
|||
handlers, err := c.GetHandlers(ctx, cmd.Params.Get(0).StringOr("all")) |
|||
if err != nil { |
|||
log.Fatalln(err) |
|||
} |
|||
|
|||
WriteHandlerInfoTable(os.Stdout, handlers) |
|||
default: |
|||
if cmd.Name != "help" { |
|||
log.Println("Unknown command:", cmd.Name) |
|||
} |
|||
|
|||
_, _ = fmt.Fprintln(os.Stderr, helpString[1:]) |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
#!/bin/bash |
|||
|
|||
printf "Building lucy...\n" |
|||
go mod download || exit 1 |
|||
go build -ldflags "-w -s" -o lucy ./cmd/lucy || exit 1 |
|||
|
|||
printf "Removing old lucy...\n" |
|||
sudo rm /usr/local/bin/lucy > /dev/null 2&>1 |
|||
|
|||
printf "Installing...\n" |
|||
sudo mv ./lucy /usr/local/bin/lucy |
Write
Preview
Loading…
Cancel
Save
Reference in new issue