main.go 736 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "fmt"
  4. "runtime"
  5. "github.com/alecthomas/kong"
  6. )
  7. type (
  8. CLI struct {
  9. Version kong.VersionFlag `help:"Show version information." short:"v"`
  10. Detect Detect `cmd:"" help:"Detect network presence and push state changes to IFTTT."`
  11. Check Check `cmd:"" help:"Check configuration."`
  12. }
  13. )
  14. var (
  15. version = "dev"
  16. commit = "none"
  17. date = "unknown"
  18. )
  19. func main() {
  20. cli := &CLI{}
  21. ctx := kong.Parse(
  22. cli,
  23. kong.Description("Home network presence detection daemon for IFTTT"), kong.UsageOnError(),
  24. kong.Vars{
  25. "version": fmt.Sprintf("presence version %v %v %v/%v %v %v", version, runtime.Version(), runtime.GOOS, runtime.GOARCH, commit, date),
  26. },
  27. )
  28. err := ctx.Run(cli)
  29. ctx.FatalIfErrorf(err)
  30. }