33 lines
666 B
Nim
33 lines
666 B
Nim
import commandeer, sockets, redis
|
|
|
|
commandline:
|
|
option hostname, string, "hostname", "h"
|
|
option optPort, int, "port", "p"
|
|
option admin, bool, "admin", ""
|
|
exitoption "help", "",
|
|
"Usage: redis-cli [--admin|--help|--hostname=<string>|--port=<int>]"
|
|
errormsg "Invalid options: please read help."
|
|
|
|
if hostname == nil:
|
|
hostname = "127.0.0.1"
|
|
|
|
if optPort == 0:
|
|
optPort = 6379
|
|
|
|
if admin:
|
|
echo "Connecting with admin permissions"
|
|
|
|
echo "hostname: ", hostname
|
|
echo "port: ", optPort
|
|
|
|
var conn: redis.Redis
|
|
|
|
try:
|
|
conn = redis.open(hostname, optPort.Port)
|
|
|
|
except:
|
|
echo "Could not connect to redis: " & getCurrentExceptionMsg()
|
|
quit()
|
|
|
|
conn.quit()
|