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.

46 lines
985 B

4 years ago
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 "alias":
  20. handleAliasCommand()
  21. case "--help":
  22. printDefaultUsage()
  23. os.Exit(0)
  24. default:
  25. fmt.Fprintf(os.Stderr, "%s: '%s' is not a recognized command\n",
  26. os.Args[0], os.Args[1])
  27. printDefaultUsage()
  28. os.Exit(1)
  29. }
  30. os.Exit(0)
  31. }
  32. func printDefaultUsage() {
  33. fmt.Printf("Usage: %s <command> ...\n", os.Args[0])
  34. fmt.Printf("See '%s <command> --help' for information", os.Args[0])
  35. fmt.Printf(" on a specific command\n")
  36. fmt.Printf("valid commands:\n")
  37. fmt.Printf(" index create, delete, refresh, or list indexes\n")
  38. fmt.Printf(" alias create, delete, replace, or list aliases\n")
  39. }