Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cmd/lk/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"context"
"fmt"
"net/http"
"slices"
"time"

"github.com/twitchtv/twirp"
"github.com/urfave/cli/v3"
Expand Down Expand Up @@ -57,9 +59,9 @@ var (
},
},
{
Name: "load",
Name: "playback",
Before: createReplayClient,
Action: loadReplay,
Action: playback,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "id",
Expand Down Expand Up @@ -160,20 +162,27 @@ func listReplays(ctx context.Context, cmd *cli.Command) error {
return err
}

slices.SortFunc(res.Replays, func(a, b *replay.ReplayInfo) int {
if a.StartTime < b.StartTime {
return 1
}
return -1
})

if cmd.Bool("json") {
util.PrintJSON(res.Replays)
} else {
table := util.CreateTable().Headers("ReplayID")
table := util.CreateTable().Headers("ReplayID", "RoomName", "StartTime")
for _, info := range res.Replays {
table.Row(info.ReplayId)
table.Row(info.ReplayId, info.RoomName, fmt.Sprint(time.Unix(0, info.StartTime)))
}
fmt.Println(table)
}

return nil
}

func loadReplay(ctx context.Context, cmd *cli.Command) error {
func playback(ctx context.Context, cmd *cli.Command) error {
ctx, err := replayClient.withAuth(ctx)
if err != nil {
return err
Expand Down
Loading