2020-04-11 11:24:23 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2020-04-11 15:26:09 +00:00
|
|
|
var redisAddr string
|
|
|
|
var redisPort string
|
2020-04-14 09:52:52 +00:00
|
|
|
var redisPassword string
|
|
|
|
var redisDB int
|
2020-04-11 15:26:09 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Register flags
|
|
|
|
rootCmd.PersistentFlags().StringVar(&redisAddr, "redis-addr", "localhost", "Redis server address")
|
|
|
|
rootCmd.PersistentFlags().StringVar(&redisPort, "redis-port", "6379", "Redis server port")
|
2020-04-14 09:52:52 +00:00
|
|
|
rootCmd.PersistentFlags().StringVar(&redisPassword, "redis-password", "", "Redis server password")
|
|
|
|
rootCmd.PersistentFlags().IntVar(&redisDB, "redis-db", 0, "Redis DB")
|
2020-04-11 15:26:09 +00:00
|
|
|
}
|
|
|
|
|
2020-04-11 11:24:23 +00:00
|
|
|
var rootCmd = &cobra.Command{
|
2020-04-12 00:15:24 +00:00
|
|
|
Use: "search [COMMANDS] [OPTIONS]",
|
2020-04-11 15:26:09 +00:00
|
|
|
Short: "A simple CLI search engine for your file system backed by Redis",
|
2020-04-12 00:15:24 +00:00
|
|
|
Example: "search index $(pwd)/fixtures",
|
2020-04-11 11:24:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Execute is a function that executes the root command
|
|
|
|
func Execute() {
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|