a command line interface for elastic (work in progress)
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.

42 lines
866 B

4 years ago
4 years ago
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "strings"
  6. // elastic "github.com/olivere/elastic/v7"
  7. // toml "github.com/pelletier/go-toml"
  8. )
  9. func main() {
  10. if len(os.Args) < 2 {
  11. fmt.Fprintf(os.Stderr, "%s: required argument missing\n", os.Args[0])
  12. printDefaultUsage()
  13. os.Exit(1)
  14. }
  15. cmd := strings.ToLower(os.Args[1])
  16. switch cmd {
  17. case "index":
  18. handleIndexCommand()
  19. case "--help":
  20. printDefaultUsage()
  21. os.Exit(0)
  22. default:
  23. fmt.Fprintf(os.Stderr, "%s: '%s' is not a recognized command\n",
  24. os.Args[0], os.Args[1])
  25. printDefaultUsage()
  26. os.Exit(1)
  27. }
  28. os.Exit(0)
  29. }
  30. func printDefaultUsage() {
  31. fmt.Printf("Usage: %s <command> ...\n", os.Args[0])
  32. fmt.Printf("See '%s <command> --help' for information", os.Args[0])
  33. fmt.Printf(" on a specific command\n")
  34. fmt.Printf("valid commands:\n")
  35. fmt.Printf(" index create, delete, or list indexes\n")
  36. }