summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/client/crawl.go8
-rw-r--r--internal/client/github.go17
-rw-r--r--internal/formatter/github.go16
-rw-r--r--internal/models/github.go6
4 files changed, 30 insertions, 17 deletions
diff --git a/internal/client/crawl.go b/internal/client/crawl.go
index f33fbcd..330bb88 100644
--- a/internal/client/crawl.go
+++ b/internal/client/crawl.go
@@ -8,10 +8,16 @@ import (
"net/url"
)
-func (c *Client) CrawlDomain(domain string, callback func(line string) error) error {
+func (c *Client) CrawlDomain(domain string, subdomains bool, callback func(line string) error) error {
path := fmt.Sprintf("/crawl/%s", url.PathEscape(domain))
fullURL := c.config.BaseURL + path
+ if subdomains {
+ params := url.Values{}
+ params.Set("subdomains", "true")
+ fullURL += "?" + params.Encode()
+ }
+
req, err := http.NewRequest(http.MethodGet, fullURL, nil)
if err != nil {
return fmt.Errorf("failed to create request: %w", err)
diff --git a/internal/client/github.go b/internal/client/github.go
index f8b7097..35e8b2c 100644
--- a/internal/client/github.go
+++ b/internal/client/github.go
@@ -58,19 +58,30 @@ func (c *Client) SearchGitHubLeads(query string, callback func(result json.RawMe
return nil
}
-func (c *Client) SearchGitHubLeadsWithParams(query, sort, exclude string, callback func(result json.RawMessage) error) error {
+func (c *Client) SearchGitHubLeadsWithParams(query, sort, exclude, format, bio string, callback func(result json.RawMessage) error) error {
path := "/github/leads"
params := url.Values{}
- params.Set("q", query)
+ if query != "" {
+ params.Set("q", query)
+ }
if sort != "" {
params.Set("sort", sort)
}
if exclude != "" {
params.Set("exclude", exclude)
}
+ if format != "" {
+ params.Set("format", format)
+ }
+ if bio != "" {
+ params.Set("bio", bio)
+ }
- fullURL := c.config.BaseURL + path + "?" + params.Encode()
+ fullURL := c.config.BaseURL + path
+ if len(params) > 0 {
+ fullURL += "?" + params.Encode()
+ }
req, err := http.NewRequest(http.MethodGet, fullURL, nil)
if err != nil {
diff --git a/internal/formatter/github.go b/internal/formatter/github.go
index 1d28af5..91a29cc 100644
--- a/internal/formatter/github.go
+++ b/internal/formatter/github.go
@@ -7,9 +7,9 @@ import (
"strings"
)
-func FormatGitHubLeads(lead *models.GitHubLeadsStreamResponse, jsonOutput bool) (string, error) {
+func FormatGitHubLeads(lead *models.GitHubLead, jsonOutput bool) (string, error) {
if jsonOutput {
- data, err := json.Marshal(lead.Lead)
+ data, err := json.Marshal(lead)
if err != nil {
return "", fmt.Errorf("failed to marshal GitHub lead: %w", err)
}
@@ -17,12 +17,12 @@ func FormatGitHubLeads(lead *models.GitHubLeadsStreamResponse, jsonOutput bool)
}
var output strings.Builder
- output.WriteString(fmt.Sprintf("Repository: %s\n", lead.Lead.Repository))
- output.WriteString(fmt.Sprintf("Author: %s\n", lead.Lead.Author))
- output.WriteString(fmt.Sprintf("Email: %s\n", lead.Lead.Email))
- output.WriteString(fmt.Sprintf("Commit: %s\n", lead.Lead.Commit))
- output.WriteString(fmt.Sprintf("Date: %s\n", lead.Lead.Date))
- output.WriteString(fmt.Sprintf("Message: %s\n", lead.Lead.Message))
+ output.WriteString(fmt.Sprintf("Repository: %s\n", lead.Repository))
+ output.WriteString(fmt.Sprintf("Author: %s\n", lead.Author))
+ output.WriteString(fmt.Sprintf("Email: %s\n", lead.Email))
+ output.WriteString(fmt.Sprintf("Commit: %s\n", lead.Commit))
+ output.WriteString(fmt.Sprintf("Date: %s\n", lead.Date))
+ output.WriteString(fmt.Sprintf("Message: %s\n", lead.Message))
output.WriteString("---\n")
return output.String(), nil
diff --git a/internal/models/github.go b/internal/models/github.go
index 722cbb8..1c9657c 100644
--- a/internal/models/github.go
+++ b/internal/models/github.go
@@ -1,6 +1,6 @@
package models
-type GitHubLeadResult struct {
+type GitHubLead struct {
Repository string `json:"repository"`
Author string `json:"author"`
Email string `json:"email"`
@@ -8,7 +8,3 @@ type GitHubLeadResult struct {
Date string `json:"date"`
Message string `json:"message"`
}
-
-type GitHubLeadsStreamResponse struct {
- Lead GitHubLeadResult `json:"lead"`
-}