Command-line utility for generating screenshot URLs. https://capture.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
741 B

  1. package main
  2. import (
  3. "code.as/captureas/go-captureas"
  4. "flag"
  5. "fmt"
  6. "os"
  7. )
  8. func main() {
  9. w := flag.Int("w", 800, "Desired width of the screenshot")
  10. h := flag.Int("h", 600, "Desired height of the screenshot")
  11. flag.Parse()
  12. if len(flag.Args()) < 1 {
  13. fmt.Println("usage: cap [url]")
  14. os.Exit(1)
  15. }
  16. url := flag.Args()[0]
  17. username := os.Getenv("CAPTUREAS_USER")
  18. secret := os.Getenv("CAPTUREAS_SECRET")
  19. if username == "" {
  20. fmt.Println("CAPTUREAS_USER not set.")
  21. }
  22. if secret == "" {
  23. fmt.Println("CAPTUREAS_SECRET not set.")
  24. }
  25. if username == "" || secret == "" {
  26. os.Exit(1)
  27. }
  28. c := captureas.NewClient(username, secret)
  29. fmt.Println(c.Capture(&captureas.CaptureParams{
  30. URL: url,
  31. Width: *w,
  32. Height: *h,
  33. }))
  34. }