X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/3589e1a7e5e0de5c5f14017f3ce9907584fbbb6d..2069d06a0bb88acf17153e2ece1ffb857d11645d:/redis-cli.c diff --git a/redis-cli.c b/redis-cli.c index e4ff5977..03755efa 100644 --- a/redis-cli.c +++ b/redis-cli.c @@ -65,6 +65,7 @@ static struct redisCommand cmdTable[] = { {"set",3,REDIS_CMD_BULK}, {"setnx",3,REDIS_CMD_BULK}, {"append",3,REDIS_CMD_BULK}, + {"substr",4,REDIS_CMD_INLINE}, {"del",-2,REDIS_CMD_INLINE}, {"exists",2,REDIS_CMD_INLINE}, {"incr",2,REDIS_CMD_INLINE}, @@ -100,8 +101,11 @@ static struct redisCommand cmdTable[] = { {"zincrby",4,REDIS_CMD_BULK}, {"zrem",3,REDIS_CMD_BULK}, {"zremrangebyscore",4,REDIS_CMD_INLINE}, + {"zmerge",-3,REDIS_CMD_INLINE}, + {"zmergeweighed",-4,REDIS_CMD_INLINE}, {"zrange",-4,REDIS_CMD_INLINE}, {"zrank",3,REDIS_CMD_BULK}, + {"zrevrank",3,REDIS_CMD_BULK}, {"zrangebyscore",-4,REDIS_CMD_INLINE}, {"zcount",4,REDIS_CMD_INLINE}, {"zrevrange",-4,REDIS_CMD_INLINE}, @@ -140,8 +144,15 @@ static struct redisCommand cmdTable[] = { {"msetnx",-3,REDIS_CMD_MULTIBULK}, {"monitor",1,REDIS_CMD_INLINE}, {"multi",1,REDIS_CMD_INLINE}, - {"exec",1,REDIS_CMD_MULTIBULK}, + {"exec",1,REDIS_CMD_INLINE}, {"discard",1,REDIS_CMD_INLINE}, + {"hset",4,REDIS_CMD_MULTIBULK}, + {"hget",3,REDIS_CMD_BULK}, + {"hdel",3,REDIS_CMD_BULK}, + {"hlen",2,REDIS_CMD_INLINE}, + {"hkeys",2,REDIS_CMD_INLINE}, + {"hvals",2,REDIS_CMD_INLINE}, + {"hgetall",2,REDIS_CMD_INLINE}, {NULL,0,0} }; @@ -419,7 +430,7 @@ static void usage() { fprintf(stderr, "example: cat /etc/passwd | redis-cli set my_passwd\n"); fprintf(stderr, "example: redis-cli get my_passwd\n"); fprintf(stderr, "example: redis-cli -r 100 lpush mylist x\n"); - fprintf(stderr, "\nRun in interactive mode: redis-cli -i \n"); + fprintf(stderr, "\nRun in interactive mode: redis-cli -i or just don't pass any command\n"); exit(1); } @@ -441,11 +452,8 @@ static char *prompt(char *line, int size) { printf(">> "); retval = fgets(line, size, stdin); } while (retval && *line == '\n'); - line[strlen(line) - 1] = '\0'; - fpurge(stdin); - return retval; } @@ -488,12 +496,10 @@ int main(int argc, char **argv) { config.interactive = 0; firstarg = parseOptions(argc,argv); - argc -= firstarg; argv += firstarg; - if (config.interactive == 1) repl(); - if (argc < 1) usage(); + if (argc == 0 || config.interactive == 1) repl(); argvcopy = convertToSds(argc, argv);