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.

main.go 887B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. flag "github.com/spf13/pflag"
  6. "github.com/ojizero/gofindup"
  7. )
  8. var (
  9. version = "dev"
  10. commit = "HEAD"
  11. date = "unknown"
  12. )
  13. func main() {
  14. var (
  15. startdir string
  16. nametofind string
  17. printversion bool
  18. )
  19. flag.BoolVarP(&printversion, "version", "v", false, "Display version info and exit program")
  20. flag.StringVarP(&startdir, "startdir", "s", "", "Directory to start searching from, if not given would search from current working directory")
  21. flag.Parse()
  22. nametofind = flag.Arg(0)
  23. if printversion {
  24. fmt.Printf("Version: %v, Build commit: %v, Released on: %v\n", version, commit, date)
  25. os.Exit(0)
  26. }
  27. findup := gofindup.Findup
  28. if startdir != "" {
  29. findup = func(name string) (string, error) {
  30. return gofindup.FindupFrom(name, startdir)
  31. }
  32. }
  33. found, err := findup(nametofind)
  34. if err != nil {
  35. panic(err)
  36. }
  37. fmt.Print(found)
  38. }