summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authors <[email protected]>2025-11-16 02:40:58 -0500
committers <[email protected]>2025-11-16 02:40:58 -0500
commit76d0cff639988ca506b1dc6e848841944c96b263 (patch)
treeb841dce1980bdb50d9f0c8f96d649a53a1778029 /cmd
parentf4c58dfee401431c37e853643d0188cd020f66d7 (diff)
downloaddborg-76d0cff639988ca506b1dc6e848841944c96b263.tar.gz
dborg-76d0cff639988ca506b1dc6e848841944c96b263.zip
docs: add comprehensive api endpoints documentation and expand cli functionalityv1.0.3
Diffstat (limited to 'cmd')
-rw-r--r--cmd/admin.go31
-rw-r--r--cmd/github.go62
-rw-r--r--cmd/x.go2
3 files changed, 94 insertions, 1 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index b0c3e13..5ef98ca 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -57,6 +57,12 @@ var adminDisableCmd = &cobra.Command{
RunE: runAdminDisable,
}
+var adminStatsCmd = &cobra.Command{
+ Use: "stats",
+ Short: "Get account information and usage statistics",
+ RunE: runAdminStats,
+}
+
func init() {
rootCmd.AddCommand(adminCmd)
adminCmd.AddCommand(adminListCmd)
@@ -65,6 +71,7 @@ func init() {
adminCmd.AddCommand(adminCreditsCmd)
adminCmd.AddCommand(adminSetCreditsCmd)
adminCmd.AddCommand(adminDisableCmd)
+ adminCmd.AddCommand(adminStatsCmd)
adminCreateCmd.Flags().IntP("credits", "c", 0, "Initial credits")
adminCreateCmd.Flags().BoolP("unlimited", "u", false, "Unlimited credits")
@@ -241,3 +248,27 @@ func runAdminDisable(cmd *cobra.Command, args []string) error {
printOutput(output)
return nil
}
+
+func runAdminStats(cmd *cobra.Command, args []string) error {
+ c, err := getAdminClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ response, err := c.GetAccountStats()
+ if err != nil {
+ return err
+ }
+
+ if err := checkError(response.Error); err != nil {
+ return err
+ }
+
+ output, err := formatter.FormatAccountStats(response, IsJSONOutput())
+ if err != nil {
+ return err
+ }
+
+ printOutput(output)
+ return nil
+}
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
+}
diff --git a/cmd/x.go b/cmd/x.go
index c5c18e4..b2554e4 100644
--- a/cmd/x.go
+++ b/cmd/x.go
@@ -99,7 +99,7 @@ func runXHistorySearch(cmd *cobra.Command, args []string) error {
}
func runXTweetsSearch(cmd *cobra.Command, args []string) error {
- c, err := newClient()
+ c, err := newUnauthenticatedClient()
if err != nil {
return err
}