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.
|
|
package main
import ( "fmt" "os" "strings" )
func main() { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "%s: required argument missing\n", os.Args[0]) printDefaultUsage() os.Exit(1) }
cmd := strings.ToLower(os.Args[1]) switch cmd { case "index", "idx", "i": handleIndexCommand()
case "alias", "a": handleAliasCommand()
case "search", "sea", "s": handleSearchCommand()
case "--help": printDefaultUsage() os.Exit(0)
default: fmt.Fprintf(os.Stderr, "%s: '%s' is not a recognized command\n", os.Args[0], os.Args[1]) printDefaultUsage() os.Exit(1) } os.Exit(0) }
func printDefaultUsage() { fmt.Printf("Usage: %s <command> ...\n", os.Args[0]) fmt.Printf("See '%s <command> --help' for information", os.Args[0]) fmt.Printf(" on a specific command\n") fmt.Printf("valid commands:\n") fmt.Printf(" index create, delete, refresh, or list indexes\n") fmt.Printf(" alias create, delete, replace, or list aliases\n") fmt.Printf(" search search an index or alias\n") }
|