2020-05-09 16:30:50 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/ledisdb/ledisdb/cmd"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-05-10 08:32:35 +03:00
|
|
|
version = "dev"
|
|
|
|
buildTag string
|
|
|
|
|
2020-05-09 16:30:50 +03:00
|
|
|
cmds = [][]string{
|
|
|
|
{"server", "run ledis server"},
|
|
|
|
{"cli", "run ledis client"},
|
|
|
|
{"repair", "repair ledis storage directory"},
|
|
|
|
{"dump", "create a snapshort of ledis"},
|
|
|
|
{"load", "load data from a snapshort"},
|
|
|
|
{"benchmark", "run the benchmarks with ledis"},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func printSubCmds() {
|
|
|
|
for _, cmd := range cmds {
|
|
|
|
printCmd(cmd[0], cmd[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func printCmd(cmd, description string) {
|
|
|
|
fmt.Printf("%s\t- %s\n", cmd, description)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2020-05-10 08:32:35 +03:00
|
|
|
fmt.Printf("Version %s", version)
|
|
|
|
if len(buildTag) > 0 {
|
|
|
|
fmt.Printf(" with tag %s", buildTag)
|
|
|
|
}
|
|
|
|
fmt.Println()
|
2020-05-09 16:30:50 +03:00
|
|
|
var subCmd string
|
|
|
|
if len(os.Args) == 1 {
|
|
|
|
subCmd = "server"
|
|
|
|
} else {
|
|
|
|
subCmd = os.Args[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
switch subCmd {
|
|
|
|
case "repair":
|
|
|
|
cmd.CmdRepair()
|
|
|
|
case "benchmark":
|
|
|
|
cmd.CmdBenchmark()
|
|
|
|
case "cli":
|
|
|
|
cmd.CmdCli()
|
|
|
|
case "dump":
|
|
|
|
cmd.CmdDump()
|
|
|
|
case "help":
|
|
|
|
printSubCmds()
|
|
|
|
case "server":
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
cmd.CmdServer()
|
|
|
|
}
|
|
|
|
}
|