Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ func AddDirectoryPrefixFlag(cmd *cobra.Command) {
func AddRefangFlag(cmd *cobra.Command) {
cmd.Flags().Bool("refang", false, "Refang an input (convert '[.]' back to '.' and so on)")
}

func AddDatasourceFlag(cmd *cobra.Command) {
cmd.Flags().StringP("datasource", "D", "scans", "Datasources to search: scans (urlscan.io), hostnames, incidents, notifications, certificates (urlscan Pro)")
}
6 changes: 5 additions & 1 deletion cmd/search/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/spf13/cobra"

"github.com/urlscan/urlscan-cli/api"
"github.com/urlscan/urlscan-cli/cmd/flags"
"github.com/urlscan/urlscan-cli/pkg/utils"
)

Expand All @@ -24,6 +25,8 @@ var countCmd = &cobra.Command{
return cmd.Usage()
}

datasource, _ := cmd.Flags().GetString("datasource")

reader := utils.StringReaderFromCmdArgs(args)
q, err := reader.ReadString()
if err != nil {
Expand All @@ -35,7 +38,7 @@ var countCmd = &cobra.Command{
return err
}

it, err := client.Search(q, api.IteratorSize(0))
it, err := client.Search(q, api.IteratorSize(0), api.IteratorDatasource(datasource))
if err != nil {
return err
}
Expand All @@ -53,5 +56,6 @@ var countCmd = &cobra.Command{
}

func init() {
flags.AddDatasourceFlag(countCmd)
RootCmd.AddCommand(countCmd)
}
2 changes: 1 addition & 1 deletion cmd/search/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func init() {
flags.AddSizeFlag(RootCmd, 100) // non-pro user's max size is 100
flags.AddLimitFlag(RootCmd)
flags.AddAllFlag(RootCmd)
flags.AddDatasourceFlag(RootCmd)
RootCmd.Flags().String("search-after", "", "For retrieving the next batch of results, value of the sort attribute of the last (oldest) result you received (comma-separated)")
RootCmd.Flags().StringP("datasource", "D", "scans", "Datasources to search: scans (urlscan.io), hostnames, incidents, notifications, certificates (urlscan Pro)")
RootCmd.Flags().StringP("collapse", "c", "", "Field to collapse results on")
}
3 changes: 2 additions & 1 deletion docs/urlscan_search_count.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ urlscan search count <query> [flags]
### Options

```
-h, --help help for count
-D, --datasource string Datasources to search: scans (urlscan.io), hostnames, incidents, notifications, certificates (urlscan Pro) (default "scans")
-h, --help help for count
```

### SEE ALSO
Expand Down