long repeat;
int dbnum;
int interactive;
+ int shutdown;
int monitor_mode;
int pubsub_mode;
int raw_output;
{"zincrby",4,CMDFLAG_NONE},
{"zrem",3,CMDFLAG_NONE},
{"zremrangebyscore",4,CMDFLAG_NONE},
- {"zmerge",-3,CMDFLAG_NONE},
- {"zmergeweighed",-4,CMDFLAG_NONE},
+ {"zunion",-4,CMDFLAG_NONE},
+ {"zinter",-4,CMDFLAG_NONE},
{"zrange",-4,CMDFLAG_NONE},
{"zrank",3,CMDFLAG_NONE},
{"zrevrank",3,CMDFLAG_NONE},
{"psubscribe",-2,CMDFLAG_NONE},
{"punsubscribe",-1,CMDFLAG_NONE},
{"publish",3,CMDFLAG_NONE},
+ {"watch",-2,CMDFLAG_NONE},
+ {"unwatch",1,CMDFLAG_NONE},
{NULL,0,CMDFLAG_NONE}
};
static int cliReadReply(int fd) {
char type;
- if (anetRead(fd,&type,1) <= 0) exit(1);
+ if (anetRead(fd,&type,1) <= 0) {
+ if (config.shutdown) return 0;
+ exit(1);
+ }
switch(type) {
case '-':
printf("(error) ");
int fd, j, retval = 0;
sds cmd;
- config.raw_output = (rc->flags & CMDFLAG_RAWOUTPUT);
if (!rc) {
fprintf(stderr,"Unknown command '%s'\n",argv[0]);
return 1;
}
+ config.raw_output = (rc->flags & CMDFLAG_RAWOUTPUT);
if ((rc->arity > 0 && argc != rc->arity) ||
(rc->arity < 0 && argc < -rc->arity)) {
fprintf(stderr,"Wrong number of arguments for '%s'\n",rc->name);
return 1;
}
+
+ if (!strcasecmp(rc->name,"shutdown")) config.shutdown = 1;
if (!strcasecmp(rc->name,"monitor")) config.monitor_mode = 1;
if (!strcasecmp(rc->name,"subscribe") ||
!strcasecmp(rc->name,"psubscribe")) config.pubsub_mode = 1;
}
retval = cliReadReply(fd);
+
if (retval) {
return retval;
}
config.hostport = 6379;
config.repeat = 1;
config.dbnum = 0;
+ config.shutdown = 0;
config.interactive = 0;
config.monitor_mode = 0;
config.pubsub_mode = 0;