1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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. If no query is provided, returns random leads.`,
Args: cobra.MaximumNArgs(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")
githubLeadsCmd.Flags().String("format", "json", "Output format (json, csv)")
githubLeadsCmd.Flags().String("bio", "false", "Include bio info (true/false) - adds company, location, website, twitter, pfp")
}
func runGitHubLeads(cmd *cobra.Command, args []string) error {
query := ""
if len(args) > 0 {
query = args[0]
}
sort, _ := cmd.Flags().GetString("sort")
exclude, _ := cmd.Flags().GetString("exclude")
format, _ := cmd.Flags().GetString("format")
bio, _ := cmd.Flags().GetString("bio")
c, err := newUnauthenticatedClient()
if err != nil {
return err
}
err = c.SearchGitHubLeadsWithParams(query, sort, exclude, format, bio, func(result json.RawMessage) error {
var lead models.GitHubLead
if err := json.Unmarshal(result, &lead); err != nil {
return err
}
output, err := formatter.FormatGitHubLeads(&lead, IsJSONOutput())
if err != nil {
return err
}
printOutput(output)
return nil
})
if err != nil {
return err
}
return nil
}
|