36 lines
695 B
Go
36 lines
695 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
keyword := flag.String("keyword", "", "Search keyword (required)")
|
|
limit := flag.Int("limit", 100, "Max posts to fetch")
|
|
flag.Parse()
|
|
|
|
if *keyword == "" {
|
|
fmt.Fprintln(os.Stderr, "-keyword is required")
|
|
os.Exit(2)
|
|
}
|
|
|
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
|
defer cancel()
|
|
|
|
// placeholder: in future wire up controller
|
|
fmt.Printf("Starting crawl for keyword=%s limit=%d\n", *keyword, *limit)
|
|
|
|
select {
|
|
case <-time.After(1 * time.Second):
|
|
fmt.Println("Done (placeholder)")
|
|
case <-ctx.Done():
|
|
fmt.Println("Cancelled")
|
|
}
|
|
}
|