this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a tool for parsing timestamps from rkeys (#436)

authored by

Jaz and committed by
GitHub
49a15727 1e3e99df

+36 -1
+36 -1
cmd/gosky/main.go
··· 18 18 "github.com/bluesky-social/indigo/api/atproto" 19 19 comatproto "github.com/bluesky-social/indigo/api/atproto" 20 20 "github.com/bluesky-social/indigo/api/bsky" 21 + "github.com/bluesky-social/indigo/atproto/syntax" 21 22 "github.com/bluesky-social/indigo/events" 22 23 "github.com/bluesky-social/indigo/events/schedulers/sequential" 23 24 lexutil "github.com/bluesky-social/indigo/lex/util" ··· 35 36 "github.com/ipld/go-car" 36 37 37 38 _ "github.com/joho/godotenv/autoload" 38 - _ "go.uber.org/automaxprocs" 39 39 40 40 "github.com/carlmjohnson/versioninfo" 41 41 logging "github.com/ipfs/go-log" ··· 93 93 getRecordCmd, 94 94 listAllRecordsCmd, 95 95 readRepoStreamCmd, 96 + parseRkey, 96 97 } 97 98 98 99 app.RunAndExitOnError() ··· 660 661 return nil 661 662 }, 662 663 } 664 + 665 + var parseRkey = &cli.Command{ 666 + Name: "parse-rkey", 667 + Usage: "get the timestamp out of a record key", 668 + Flags: []cli.Flag{ 669 + &cli.StringFlag{ 670 + Name: "format", 671 + Value: "rfc3339", 672 + Usage: "output format (rfc3339 or unix)", 673 + }, 674 + }, 675 + ArgsUsage: `<rkey>`, 676 + Action: func(cctx *cli.Context) error { 677 + arg := cctx.Args().First() 678 + if arg == "" { 679 + return cli.Exit("must specify record key", 127) 680 + } 681 + 682 + tid, err := syntax.ParseTID(arg) 683 + if err != nil { 684 + return cli.Exit(fmt.Errorf("failed to parse record key (%s) as a TID: %w", arg, err), 127) 685 + } 686 + 687 + switch cctx.String("format") { 688 + case "rfc3339": 689 + fmt.Println(tid.Time().Format(time.RFC3339Nano)) 690 + case "unix": 691 + fmt.Println(tid.Time().Unix()) 692 + default: 693 + return cli.Exit(fmt.Errorf("unknown format: %s", cctx.String("format")), 127) 694 + } 695 + return nil 696 + }, 697 + }