summaryrefslogtreecommitdiffstats
path: root/cmd/crawl.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/crawl.go')
-rw-r--r--cmd/crawl.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/cmd/crawl.go b/cmd/crawl.go
new file mode 100644
index 0000000..3587eb0
--- /dev/null
+++ b/cmd/crawl.go
@@ -0,0 +1,37 @@
+package cmd
+
+import (
+ "fmt"
+
+ "github.com/spf13/cobra"
+)
+
+var crawlCmd = &cobra.Command{
+ Use: "crawl [domain]",
+ Short: "Crawl domain",
+ Long: `Resolves a domain using httpx and crawls it using katana. Returns discovered links as plain text, one per line, streamed in real-time. Supports both http:// and https:// URLs.`,
+ Args: cobra.ExactArgs(1),
+ RunE: runCrawl,
+}
+
+func init() {
+ rootCmd.AddCommand(crawlCmd)
+}
+
+func runCrawl(cmd *cobra.Command, args []string) error {
+ c, err := newUnauthenticatedClient()
+ if err != nil {
+ return err
+ }
+
+ err = c.CrawlDomain(args[0], func(line string) error {
+ fmt.Println(line)
+ return nil
+ })
+
+ if err != nil {
+ return err
+ }
+
+ return nil
+}