From 76d0cff639988ca506b1dc6e848841944c96b263 Mon Sep 17 00:00:00 2001 From: s Date: Sun, 16 Nov 2025 02:40:58 -0500 Subject: docs: add comprehensive api endpoints documentation and expand cli functionality --- cmd/github.go | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 cmd/github.go (limited to 'cmd/github.go') diff --git a/cmd/github.go b/cmd/github.go new file mode 100644 index 0000000..6cc1951 --- /dev/null +++ b/cmd/github.go @@ -0,0 +1,62 @@ +package cmd + +import ( + "encoding/json" + + "git.db.org.ai/dborg/internal/formatter" + "git.db.org.ai/dborg/internal/models" + "github.com/spf13/cobra" +) + +var githubCmd = &cobra.Command{ + Use: "github", + Short: "GitHub leads scanner", + Long: `Scans GitHub repositories for commit author information based on search query`, +} + +var githubLeadsCmd = &cobra.Command{ + Use: "leads [query]", + Short: "Search GitHub repositories for commit authors", + Long: `Scans GitHub repositories for commit author information based on search query and streams results as NDJSON`, + Args: cobra.ExactArgs(1), + RunE: runGitHubLeads, +} + +func init() { + rootCmd.AddCommand(githubCmd) + githubCmd.AddCommand(githubLeadsCmd) + + githubLeadsCmd.Flags().String("sort", "stars", "Sort method (stars, forks, updated)") + githubLeadsCmd.Flags().String("exclude", "", "Comma-separated terms to exclude from search") +} + +func runGitHubLeads(cmd *cobra.Command, args []string) error { + sort, _ := cmd.Flags().GetString("sort") + exclude, _ := cmd.Flags().GetString("exclude") + + c, err := newUnauthenticatedClient() + if err != nil { + return err + } + + err = c.SearchGitHubLeadsWithParams(args[0], sort, exclude, func(result json.RawMessage) error { + var streamResp models.GitHubLeadsStreamResponse + if err := json.Unmarshal(result, &streamResp); err != nil { + return err + } + + output, err := formatter.FormatGitHubLeads(&streamResp, IsJSONOutput()) + if err != nil { + return err + } + + printOutput(output) + return nil + }) + + if err != nil { + return err + } + + return nil +} -- cgit v1.2.3