this repo has no description
13
fork

Configure Feed

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

upgrade to cli/v3

+68 -65
+9 -8
cmd/astrolabe/main.go
··· 1 1 package main 2 2 3 3 import ( 4 + "context" 4 5 "fmt" 5 6 slogging "log/slog" 6 7 "os" 7 8 9 + _ "github.com/joho/godotenv/autoload" 10 + 8 11 "github.com/earthboundkid/versioninfo/v2" 9 - "github.com/urfave/cli/v2" 10 - 11 - _ "github.com/joho/godotenv/autoload" 12 + "github.com/urfave/cli/v3" 12 13 ) 13 14 14 15 var ( ··· 25 26 26 27 func run(args []string) error { 27 28 28 - app := cli.App{ 29 + app := cli.Command{ 29 30 Name: "astrolabe", 30 31 Usage: "public web interface to explore atproto network content", 31 32 } ··· 41 42 Usage: "Specify the local IP/port to bind to", 42 43 Required: false, 43 44 Value: ":8400", 44 - EnvVars: []string{"ASTROLABE_BIND"}, 45 + Sources: cli.EnvVars("ASTROLABE_BIND"), 45 46 }, 46 47 &cli.BoolFlag{ 47 48 Name: "debug", 48 49 Usage: "Enable debug mode", 49 50 Value: false, 50 51 Required: false, 51 - EnvVars: []string{"DEBUG"}, 52 + Sources: cli.EnvVars("DEBUG"), 52 53 }, 53 54 }, 54 55 }, 55 56 &cli.Command{ 56 57 Name: "version", 57 58 Usage: "print version", 58 - Action: func(cctx *cli.Context) error { 59 + Action: func(ctx context.Context, cmd *cli.Command) error { 59 60 fmt.Println(version) 60 61 return nil 61 62 }, 62 63 }, 63 64 } 64 65 65 - return app.Run(args) 66 + return app.Run(context.Background(), args) 66 67 }
+4 -4
cmd/astrolabe/service.go
··· 18 18 "github.com/labstack/echo/v4" 19 19 "github.com/labstack/echo/v4/middleware" 20 20 slogecho "github.com/samber/slog-echo" 21 - "github.com/urfave/cli/v2" 21 + "github.com/urfave/cli/v3" 22 22 ) 23 23 24 24 //go:embed static/* ··· 30 30 dir identity.Directory 31 31 } 32 32 33 - func serve(cctx *cli.Context) error { 34 - debug := cctx.Bool("debug") 35 - httpAddress := cctx.String("bind") 33 + func serve(ctx context.Context, cmd *cli.Command) error { 34 + debug := cmd.Bool("debug") 35 + httpAddress := cmd.String("bind") 36 36 37 37 e := echo.New() 38 38
+10 -9
cmd/athome/main.go
··· 1 1 package main 2 2 3 3 import ( 4 + "context" 4 5 "fmt" 5 6 slogging "log/slog" 6 7 "os" 7 8 8 - "github.com/earthboundkid/versioninfo/v2" 9 - "github.com/urfave/cli/v2" 10 - 11 9 _ "github.com/joho/godotenv/autoload" 10 + 11 + "github.com/earthboundkid/versioninfo/v2" 12 + "github.com/urfave/cli/v3" 12 13 ) 13 14 14 15 var ( ··· 25 26 26 27 func run(args []string) error { 27 28 28 - app := cli.App{ 29 + app := cli.Command{ 29 30 Name: "athome", 30 31 Usage: "public web interface to bluesky account content", 31 32 } ··· 40 41 Name: "appview-host", 41 42 Usage: "method, hostname, and port of AppView instance", 42 43 Value: "https://api.bsky.app", 43 - EnvVars: []string{"ATP_APPVIEW_HOST"}, 44 + Sources: cli.EnvVars("ATP_APPVIEW_HOST"), 44 45 }, 45 46 &cli.StringFlag{ 46 47 Name: "bind", 47 48 Usage: "Specify the local IP/port to bind to", 48 49 Required: false, 49 50 Value: ":8200", 50 - EnvVars: []string{"ATHOME_BIND"}, 51 + Sources: cli.EnvVars("ATHOME_BIND"), 51 52 }, 52 53 &cli.BoolFlag{ 53 54 Name: "debug", 54 55 Usage: "Enable debug mode", 55 56 Value: false, 56 57 Required: false, 57 - EnvVars: []string{"DEBUG"}, 58 + Sources: cli.EnvVars("DEBUG"), 58 59 }, 59 60 }, 60 61 }, 61 62 &cli.Command{ 62 63 Name: "version", 63 64 Usage: "print version", 64 - Action: func(cctx *cli.Context) error { 65 + Action: func(ctx context.Context, cmd *cli.Command) error { 65 66 fmt.Println(version) 66 67 return nil 67 68 }, 68 69 }, 69 70 } 70 71 71 - return app.Run(args) 72 + return app.Run(context.Background(), args) 72 73 }
+5 -5
cmd/athome/service.go
··· 21 21 "github.com/labstack/echo/v4" 22 22 "github.com/labstack/echo/v4/middleware" 23 23 slogecho "github.com/samber/slog-echo" 24 - "github.com/urfave/cli/v2" 24 + "github.com/urfave/cli/v3" 25 25 ) 26 26 27 27 //go:embed static/* ··· 35 35 defaultHandle syntax.Handle 36 36 } 37 37 38 - func serve(cctx *cli.Context) error { 39 - debug := cctx.Bool("debug") 40 - httpAddress := cctx.String("bind") 41 - appviewHost := cctx.String("appview-host") 38 + func serve(ctx context.Context, cmd *cli.Command) error { 39 + debug := cmd.Bool("debug") 40 + httpAddress := cmd.String("bind") 41 + appviewHost := cmd.String("appview-host") 42 42 43 43 dh, err := syntax.ParseHandle("atproto.com") 44 44 if err != nil {
+18 -16
cmd/handlr/main.go
··· 1 1 package main 2 2 3 3 import ( 4 + "context" 4 5 "log/slog" 5 6 "net/http" 6 7 "os" 7 8 "strings" 8 9 "time" 9 10 11 + _ "github.com/joho/godotenv/autoload" 12 + 10 13 "github.com/bluesky-social/indigo/atproto/syntax" 11 14 "github.com/hashicorp/golang-lru/v2/expirable" 12 - _ "github.com/joho/godotenv/autoload" 13 - cli "github.com/urfave/cli/v2" 15 + "github.com/urfave/cli/v3" 14 16 ) 15 17 16 18 func main() { ··· 22 24 23 25 func run(args []string) error { 24 26 25 - app := cli.App{ 27 + app := cli.Command{ 26 28 Name: "handlr", 27 29 Usage: "atproto handle DNS TXT proxy demon", 28 30 } ··· 32 34 Name: "bind", 33 35 Usage: "local UDP IP and port to listen on. note that DNS port 53 requires superuser on most systems", 34 36 Value: ":5333", 35 - EnvVars: []string{"HANDLR_BIND"}, 37 + Sources: cli.EnvVars("HANDLR_BIND"), 36 38 }, 37 39 &cli.StringFlag{ 38 40 Name: "backend-host", 39 41 Usage: "HTTP method, hostname, and port of backend resolution service", 40 42 Value: "http://localhost:5000", 41 - EnvVars: []string{"HANDLR_BACKEND_HOST"}, 43 + Sources: cli.EnvVars("HANDLR_BACKEND_HOST"), 42 44 }, 43 45 &cli.StringFlag{ 44 46 Name: "domain-suffix", 45 47 Usage: "domain suffix to filter handles (don't include trailing period)", 46 - EnvVars: []string{"HANDLR_DOMAIN_SUFFIX"}, 48 + Sources: cli.EnvVars("HANDLR_DOMAIN_SUFFIX"), 47 49 }, 48 50 &cli.IntFlag{ 49 51 Name: "ttl", 50 52 Usage: "TTL for both DNS TXT responses, and internal caching", 51 53 Value: 5 * 60, 52 - EnvVars: []string{"HANDLR_TTL"}, 54 + Sources: cli.EnvVars("HANDLR_TTL"), 53 55 }, 54 56 &cli.StringFlag{ 55 57 Name: "log-level", 56 58 Usage: "log level (debug, info, warn, error)", 57 59 Value: "info", 58 - EnvVars: []string{"HANDLR_LOG_LEVEL", "LOG_LEVEL"}, 60 + Sources: cli.EnvVars("HANDLR_LOG_LEVEL", "LOG_LEVEL"), 59 61 }, 60 62 } 61 63 app.Commands = []*cli.Command{ ··· 66 68 Flags: flags, 67 69 }, 68 70 } 69 - return app.Run(args) 71 + return app.Run(context.Background(), args) 70 72 } 71 73 72 - func runServe(cctx *cli.Context) error { 74 + func runServe(ctx context.Context, cmd *cli.Command) error { 73 75 74 76 logLevel := slog.LevelInfo 75 - switch strings.ToLower(cctx.String("log-level")) { 77 + switch strings.ToLower(cmd.String("log-level")) { 76 78 case "debug": 77 79 logLevel = slog.LevelDebug 78 80 case "info": ··· 90 92 91 93 // set a minimum for the internal cache 92 94 var cache *expirable.LRU[syntax.Handle, syntax.DID] 93 - ttl := cctx.Int("ttl") 95 + ttl := cmd.Int("ttl") 94 96 if ttl != 0 { 95 97 cache = expirable.NewLRU[syntax.Handle, syntax.DID](10_000, nil, time.Second*time.Duration(ttl)) 96 98 } 97 99 client := http.Client{Timeout: time.Second * 5} 98 100 hr := HTTPResolver{ 99 101 client: &client, 100 - backendHost: cctx.String("backend-host"), 101 - suffix: cctx.String("domain-suffix"), 102 - ttl: cctx.Int("ttl"), 102 + backendHost: cmd.String("backend-host"), 103 + suffix: cmd.String("domain-suffix"), 104 + ttl: cmd.Int("ttl"), 103 105 cache: cache, 104 106 } 105 - return hr.Run(cctx.String("bind")) 107 + return hr.Run(cmd.String("bind")) 106 108 }
+16 -17
cmd/lexidex/main.go
··· 1 1 package main 2 2 3 3 import ( 4 + "context" 4 5 "fmt" 5 6 "log/slog" 6 7 "os" ··· 10 11 "github.com/bluesky-social/indigo/atproto/syntax" 11 12 12 13 "github.com/earthboundkid/versioninfo/v2" 13 - "github.com/urfave/cli/v2" 14 + "github.com/urfave/cli/v3" 14 15 "gorm.io/driver/sqlite" 15 16 "gorm.io/gorm" 16 17 ) ··· 28 29 29 30 func run(args []string) error { 30 31 31 - app := cli.App{ 32 + app := cli.Command{ 32 33 Name: "lexidex", 33 34 Usage: "atproto Lexicon index and schema browser", 34 35 Flags: []cli.Flag{ ··· 36 37 Name: "sqlite-path", 37 38 Usage: "Database file path", 38 39 Value: "./lexidex.sqlite", 39 - EnvVars: []string{"LEXIDEX_SQLITE_PATH"}, 40 + Sources: cli.EnvVars("LEXIDEX_SQLITE_PATH"), 40 41 }, 41 42 &cli.StringFlag{ 42 43 Name: "jetstream-host", 43 44 Usage: "URL (scheme, host, path) to jetstream host for firehose consumption", 44 45 Value: "wss://jetstream2.us-west.bsky.network/subscribe", 45 - EnvVars: []string{"LEXIDEX_JETSTREAM_HOST"}, 46 + Sources: cli.EnvVars("LEXIDEX_JETSTREAM_HOST"), 46 47 }, 47 48 }, 48 49 } ··· 58 59 Usage: "Specify the local IP/port to bind to", 59 60 Required: false, 60 61 Value: ":8500", 61 - EnvVars: []string{"LEXIDEX_BIND"}, 62 + Sources: cli.EnvVars("LEXIDEX_BIND"), 62 63 }, 63 64 }, 64 65 }, ··· 75 76 &cli.Command{ 76 77 Name: "version", 77 78 Usage: "print version", 78 - Action: func(cctx *cli.Context) error { 79 + Action: func(ctx context.Context, cmd *cli.Command) error { 79 80 fmt.Println(version) 80 81 return nil 81 82 }, 82 83 }, 83 84 } 84 85 85 - return app.Run(args) 86 + return app.Run(context.Background(), args) 86 87 } 87 88 88 - func runServe(cctx *cli.Context) error { 89 - srv, err := NewWebServer(cctx) 89 + func runServe(ctx context.Context, cmd *cli.Command) error { 90 + srv, err := NewWebServer(ctx, cmd) 90 91 if err != nil { 91 92 return err 92 93 } ··· 97 98 return srv.RunSignalHandler() 98 99 } 99 100 100 - func runCrawl(cctx *cli.Context) error { 101 - ctx := cctx.Context 101 + func runCrawl(ctx context.Context, cmd *cli.Command) error { 102 102 103 - s := cctx.Args().First() 103 + s := cmd.Args().First() 104 104 if s == "" { 105 105 return fmt.Errorf("need to provide Lexicon NSID as an argument") 106 106 } ··· 109 109 return err 110 110 } 111 111 112 - db, err := gorm.Open(sqlite.Open(cctx.String("sqlite-path"))) 112 + db, err := gorm.Open(sqlite.Open(cmd.String("sqlite-path"))) 113 113 if err != nil { 114 114 return fmt.Errorf("failed to open db: %w", err) 115 115 } ··· 118 118 return CrawlLexicon(ctx, db, nsid, "cli") 119 119 } 120 120 121 - func runLoadDir(cctx *cli.Context) error { 122 - ctx := cctx.Context 121 + func runLoadDir(ctx context.Context, cmd *cli.Command) error { 123 122 124 - p := cctx.Args().First() 123 + p := cmd.Args().First() 125 124 if p == "" { 126 125 return fmt.Errorf("need to provide directory path as an argument") 127 126 } 128 127 129 - db, err := gorm.Open(sqlite.Open(cctx.String("sqlite-path"))) 128 + db, err := gorm.Open(sqlite.Open(cmd.String("sqlite-path"))) 130 129 if err != nil { 131 130 return fmt.Errorf("failed to open db: %w", err) 132 131 }
+6 -6
cmd/lexidex/web_server.go
··· 19 19 "github.com/labstack/echo/v4" 20 20 "github.com/labstack/echo/v4/middleware" 21 21 slogecho "github.com/samber/slog-echo" 22 - "github.com/urfave/cli/v2" 22 + "github.com/urfave/cli/v3" 23 23 "gorm.io/driver/sqlite" 24 24 "gorm.io/gorm" 25 25 ) ··· 35 35 jetstreamHost string 36 36 } 37 37 38 - func NewWebServer(cctx *cli.Context) (*WebServer, error) { 39 - debug := cctx.Bool("debug") 40 - httpAddress := cctx.String("bind") 41 - jetstreamHost := cctx.String("jetstream-host") 42 - db, err := gorm.Open(sqlite.Open(cctx.String("sqlite-path"))) 38 + func NewWebServer(ctx context.Context, cmd *cli.Command) (*WebServer, error) { 39 + debug := cmd.Bool("debug") 40 + httpAddress := cmd.String("bind") 41 + jetstreamHost := cmd.String("jetstream-host") 42 + db, err := gorm.Open(sqlite.Open(cmd.String("sqlite-path"))) 43 43 if err != nil { 44 44 return nil, fmt.Errorf("failed to open db: %w", err) 45 45 }