diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/flyscrape/run.go | 4 | ||||
| -rw-r--r-- | cmd/flyscrape/watch.go | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/cmd/flyscrape/run.go b/cmd/flyscrape/run.go index cf8f8cf..8e83ca8 100644 --- a/cmd/flyscrape/run.go +++ b/cmd/flyscrape/run.go @@ -19,6 +19,7 @@ type RunCommand struct{} func (c *RunCommand) Run(args []string) error { fs := flag.NewFlagSet("flyscrape-run", flag.ContinueOnError) noPrettyPrint := fs.Bool("no-pretty-print", false, "no-pretty-print") + proxy := fs.String("proxy", "", "proxy") fs.Usage = c.Usage if err := fs.Parse(args); err != nil { @@ -44,6 +45,9 @@ func (c *RunCommand) Run(args []string) error { ScrapeOptions: opts, ScrapeFunc: scrape, } + if *proxy != "" { + svc.FetchFunc = flyscrape.ProxiedFetch(*proxy) + } count := 0 start := time.Now() diff --git a/cmd/flyscrape/watch.go b/cmd/flyscrape/watch.go index 02a3b45..777ae8a 100644 --- a/cmd/flyscrape/watch.go +++ b/cmd/flyscrape/watch.go @@ -18,6 +18,7 @@ type WatchCommand struct{} func (c *WatchCommand) Run(args []string) error { fs := flag.NewFlagSet("flyscrape-watch", flag.ContinueOnError) + proxy := fs.String("proxy", "", "proxy") fs.Usage = c.Usage if err := fs.Parse(args); err != nil { @@ -28,7 +29,14 @@ func (c *WatchCommand) Run(args []string) error { return fmt.Errorf("too many arguments") } - fetch := flyscrape.CachedFetch() + var fetch flyscrape.FetchFunc + if *proxy != "" { + fetch = flyscrape.ProxiedFetch(*proxy) + } else { + fetch = flyscrape.Fetch() + } + + fetch = flyscrape.CachedFetch(fetch) script := fs.Arg(0) err := flyscrape.Watch(script, func(s string) error { |