Example #1
0
static void usage()
{
	sds version = cliVersion();
	fprintf(stderr,
	        "redislite-cli %s\n"
	        "\n"
	        "Usage: redislite-cli [OPTIONS] [cmd [arg [arg ...]]]\n"
	        "  -f <filename>    Db file name\n"
	        "  -r <repeat>      Execute specified command N times\n"
	        "  -x               Read last argument from STDIN\n"
	        "  -d <delimiter>   Multi-bulk delimiter in for raw formatting (default: \\n)\n"
	        "  --raw            Use raw formatting for replies (default when STDOUT is not a tty)\n"
	        "  --help           Output this help and exit\n"
	        "  --version        Output version and exit\n"
	        "\n"
	        "Examples:\n"
	        "  cat /etc/passwd | redislite-cli -x set mypasswd\n"
	        "  redislite-cli get mypasswd\n"
	        "  redislite-cli -r 100 lpush mylist x\n"
	        "\n"
	        "When no command is given, redislite-cli starts in interactive mode.\n"
	        "Type \"help\" in interactive mode for information on available commands.\n"
	        "\n",
	        version);
	sdsfree(version);
	exit(1);
}
Example #2
0
static void usage() {
    sds version = cliVersion();
    fprintf(stderr,
"redis-cli %s\n"
"\n"
"Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]\n"
"  -h <hostname>    Server hostname (default: 127.0.0.1)\n"
"  -p <port>        Server port (default: 6379)\n"
"  -s <socket>      Server socket (overrides hostname and port)\n"
"  -a <password>    Password to use when connecting to the server\n"
"  -r <repeat>      Execute specified command N times\n"
"  -i <interval>    When -r is used, waits <interval> seconds per command.\n"
"                   It is possible to specify sub-second times like -i 0.1.\n"
"  -n <db>          Database number\n"
"  -x               Read last argument from STDIN\n"
"  -d <delimiter>   Multi-bulk delimiter in for raw formatting (default: \\n)\n"
"  --raw            Use raw formatting for replies (default when STDOUT is not a tty)\n"
"  --latency        Enter a special mode continuously sampling latency.\n"
"  --help           Output this help and exit\n"
"  --version        Output version and exit\n"
"\n"
"Examples:\n"
"  cat /etc/passwd | redis-cli -x set mypasswd\n"
"  redis-cli get mypasswd\n"
"  redis-cli -r 100 lpush mylist x\n"
"  redis-cli -r 100 -i 1 info | grep used_memory_human:\n"
"\n"
"When no command is given, redis-cli starts in interactive mode.\n"
"Type \"help\" in interactive mode for information on available commands.\n"
"\n",
        version);
    sdsfree(version);
    exit(1);
}
Example #3
0
static int parseOptions(int argc, char **argv) {
    int i;

    for (i = 1; i < argc; i++) {
        int lastarg = i==argc-1;

        if (!strcmp(argv[i],"-h") && !lastarg) {
            sdsfree(config.hostip);
            config.hostip = sdsnew(argv[++i]);
        } else if (!strcmp(argv[i],"-h") && lastarg) {
            usage();
        } else if (!strcmp(argv[i],"--help")) {
            usage();
        } else if (!strcmp(argv[i],"-x")) {
            config.stdinarg = 1;
        } else if (!strcmp(argv[i],"-p") && !lastarg) {
            config.hostport = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-s") && !lastarg) {
            config.hostsocket = argv[++i];
        } else if (!strcmp(argv[i],"-r") && !lastarg) {
            config.repeat = strtoll(argv[++i],NULL,10);
        } else if (!strcmp(argv[i],"-i") && !lastarg) {
            double seconds = atof(argv[++i]);
            config.interval = seconds*1000000;
        } else if (!strcmp(argv[i],"-n") && !lastarg) {
            config.dbnum = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-a") && !lastarg) {
            config.auth = argv[++i];
        } else if (!strcmp(argv[i],"--raw")) {
            config.output = OUTPUT_RAW;
        } else if (!strcmp(argv[i],"--csv")) {
            config.output = OUTPUT_CSV;
        } else if (!strcmp(argv[i],"--latency")) {
            config.latency_mode = 1;
        } else if (!strcmp(argv[i],"--slave")) {
            config.slave_mode = 1;
        } else if (!strcmp(argv[i],"--pipe")) {
            config.pipe_mode = 1;
        } else if (!strcmp(argv[i],"--bigkeys")) {
            config.bigkeys = 1;
        } else if (!strcmp(argv[i],"--eval") && !lastarg) {
            config.eval = argv[++i];
        } else if (!strcmp(argv[i],"-c")) {
            config.cluster_mode = 1;
        } else if (!strcmp(argv[i],"-d") && !lastarg) {
            sdsfree(config.mb_delim);
            config.mb_delim = sdsnew(argv[++i]);
        } else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) {
            sds version = cliVersion();
            printf("redis-cli %s\n", version);
            sdsfree(version);
            exit(0);
        } else {
            break;
        }
    }
    return i;
}
Example #4
0
static void
cliInfo(char *cmdline) {
    cliVersion(NULL);
    cli_print_serial();
    cli_print_hwaddr();
    cli_print_link();
    cli_print_netif();
    cliUptime(NULL);
    cli_printf("System clock:   %d Hz (nominal)\r\n", (int)system_frequency);
}
Example #5
0
/* Print generic help. */
static void cliOutputGenericHelp() {
    sds version = cliVersion();
    printf(
        "redis-cli %s\r\n"
        "Type: \"help @<group>\" to get a list of commands in <group>\r\n"
        "      \"help <command>\" for help on <command>\r\n"
        "      \"help <tab>\" to get a list of possible help topics\r\n"
        "      \"quit\" to exit\r\n",
        version
    );
    sdsfree(version);
}
Example #6
0
static int parseOptions(int argc, char **argv) {
    int i;

    for (i = 1; i < argc; i++) {
        int lastarg = i==argc-1;

        if (!strcmp(argv[i],"-h") && !lastarg) {
            sdsfree(config.hostip);
            config.hostip = sdsnew(argv[i+1]);
            i++;
        } else if (!strcmp(argv[i],"-h") && lastarg) {
            usage();
        } else if (!strcmp(argv[i],"--help")) {
            usage();
        } else if (!strcmp(argv[i],"-x")) {
            config.stdinarg = 1;
        } else if (!strcmp(argv[i],"-p") && !lastarg) {
            config.hostport = atoi(argv[i+1]);
            i++;
        } else if (!strcmp(argv[i],"-s") && !lastarg) {
            config.hostsocket = argv[i+1];
            i++;
        } else if (!strcmp(argv[i],"-r") && !lastarg) {
            config.repeat = strtoll(argv[i+1],NULL,10);
            i++;
        } else if (!strcmp(argv[i],"-n") && !lastarg) {
            config.dbnum = atoi(argv[i+1]);
            i++;
        } else if (!strcmp(argv[i],"-a") && !lastarg) {
            config.auth = argv[i+1];
            i++;
        } else if (!strcmp(argv[i],"--raw")) {
            config.raw_output = 1;
        } else if (!strcmp(argv[i],"-d") && !lastarg) {
            sdsfree(config.mb_delim);
            config.mb_delim = sdsnew(argv[i+1]);
            i++;
        } else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) {
            sds version = cliVersion();
            printf("redis-cli %s\n", version);
            sdsfree(version);
            exit(0);
        } else {
            break;
        }
    }
    return i;
}
Example #7
0
static int parseOptions(int argc, char **argv)
{
	int i;

	for (i = 1; i < argc; i++) {
		int lastarg = i == argc - 1;

		if (!strcmp(argv[i], "-f")) {
			sdsfree(config.filename);
			config.filename = sdsnew(argv[i + 1]);
			i++;
		}
		else if (!strcmp(argv[i], "-h")) {
			usage();
		}
		else if (!strcmp(argv[i], "--help")) {
			usage();
		}
		else if (!strcmp(argv[i], "-x")) {
			config.stdinarg = 1;
		}
		else if (!strcmp(argv[i], "-r") && !lastarg) {
			config.repeat = strtoll(argv[i + 1], NULL, 10);
			i++;
		}
		else if (!strcmp(argv[i], "--raw")) {
			config.raw_output = 1;
		}
		else if (!strcmp(argv[i], "-d") && !lastarg) {
			sdsfree(config.mb_delim);
			config.mb_delim = sdsnew(argv[i + 1]);
			i++;
		}
		else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
			sds version = cliVersion();
			printf("redislite-cli %s\n", version);
			sdsfree(version);
			exit(0);
		}
		else {
			break;
		}
	}
	return i;
}
Example #8
0
static void usage() {
    sds version = cliVersion();
    fprintf(stderr,
"redis-cli %s\n"
"\n"
"Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]\n"
"  -h <hostname>     Server hostname (default: 127.0.0.1)\n"
"  -p <port>         Server port (default: 6379)\n"
"  -s <socket>       Server socket (overrides hostname and port)\n"
"  -a <password>     Password to use when connecting to the server\n"
"  -r <repeat>       Execute specified command N times\n"
"  -i <interval>     When -r is used, waits <interval> seconds per command.\n"
"                    It is possible to specify sub-second times like -i 0.1\n"
"  -n <db>           Database number\n"
"  -x                Read last argument from STDIN\n"
"  -d <delimiter>    Multi-bulk delimiter in for raw formatting (default: \\n)\n"
"  -c                Enable cluster mode (follow -ASK and -MOVED redirections)\n"
"  --raw             Use raw formatting for replies (default when STDOUT is\n"
"                    not a tty)\n"
"  --latency         Enter a special mode continuously sampling latency\n"
"  --latency-history Like --latency but tracking latency changes over time.\n"
"                    Default time interval is 15 sec. Change it using -i.\n"
"  --slave           Simulate a slave showing commands received from the master\n"
"  --rdb <filename>  Transfer an RDB dump from remote server to local file.\n"
"  --pipe            Transfer raw Redis protocol from stdin to server\n"
"  --bigkeys         Sample Redis keys looking for big keys\n"
"  --eval <file>     Send an EVAL command using the Lua script at <file>\n"
"  --help            Output this help and exit\n"
"  --version         Output version and exit\n"
"\n"
"Examples:\n"
"  cat /etc/passwd | redis-cli -x set mypasswd\n"
"  redis-cli get mypasswd\n"
"  redis-cli -r 100 lpush mylist x\n"
"  redis-cli -r 100 -i 1 info | grep used_memory_human:\n"
"  redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n"
"  (Note: when using --eval the comma separates KEYS[] from ARGV[] items)\n"
"\n"
"When no command is given, redis-cli starts in interactive mode.\n"
"Type \"help\" in interactive mode for information on available commands.\n"
"\n",
        version);
    sdsfree(version);
    exit(1);
}
Example #9
0
static void cliDump(char *cmdline)
{
    (void)cmdline;
    unsigned int i, channel;
    char buf[16];
    float thr, roll, pitch, yaw;
    uint32_t mask;
    const clivalue_t *setval;

    cliVersion(NULL);
    printf("Current Config: Copy everything below here...\r\n");

    // print out aux switches
    cliAux("");

    // print out current motor mix
    printf("mixer %s\r\n", mixerNames[mcfg.mixerConfiguration - 1]);

    // print custom mix if exists
    if (mcfg.customMixer[0].throttle != 0.0f) {
        for (i = 0; i < MAX_MOTORS; i++) {
            if (mcfg.customMixer[i].throttle == 0.0f)
                break;
            thr = mcfg.customMixer[i].throttle;
            roll = mcfg.customMixer[i].roll;
            pitch = mcfg.customMixer[i].pitch;
            yaw = mcfg.customMixer[i].yaw;
            printf("cmix %d", i + 1);
            if (thr < 0)
                printf(" ");
            printf("%s", ftoa(thr, buf));
            if (roll < 0)
                printf(" ");
            printf("%s", ftoa(roll, buf));
            if (pitch < 0)
                printf(" ");
            printf("%s", ftoa(pitch, buf));
            if (yaw < 0)
                printf(" ");
            printf("%s\r\n", ftoa(yaw, buf));
        }
        printf("cmix %d 0 0 0 0\r\n", i + 1);
    }

    // print custom servo mixer if exists
    if (mcfg.customServoMixer[0].rate != 0) {
        for (i = 0; i < MAX_SERVO_RULES; i++) {
            if (mcfg.customServoMixer[i].rate == 0)
                break;
            printf("smix %d ", i + 1);
            printf("%d ", mcfg.customServoMixer[i].targetChannel + 1);
            printf("%d ", mcfg.customServoMixer[i].fromChannel + 1);
            printf("%d ", mcfg.customServoMixer[i].rate);
            printf("%d ", mcfg.customServoMixer[i].speed);
            printf("%d ", mcfg.customServoMixer[i].min);
            printf("%d ", mcfg.customServoMixer[i].max);
            printf("%d\r\n", mcfg.customServoMixer[i].box);
        }
        printf("smix %d 0 0 0 0\r\n", i + 1);
    }

    // print servo directions
    for (i = 0; i < MAX_SERVOS; i++)
        for (channel = 0; channel < INPUT_ITEMS; channel++)
            if (cfg.servoConf[i].direction & (1 << channel))
                printf("smix direction %d %d -1\r\n", i + 1 , channel + 1);

    // print servo config
    for (i = 0; i < MAX_SERVOS; i++)
        printf("servo %d %d %d %d %d\r\n", i + 1, cfg.servoConf[i].min, cfg.servoConf[i].middle, cfg.servoConf[i].max, cfg.servoConf[i].rate);

    // print enabled features
    mask = featureMask();
    for (i = 0; ; i++) { // disable all feature first
        if (featureNames[i] == NULL)
            break;
        printf("feature -%s\r\n", featureNames[i]);
    }
    for (i = 0; ; i++) {  // reenable what we want.
        if (featureNames[i] == NULL)
            break;
        if (mask & (1 << i))
            printf("feature %s\r\n", featureNames[i]);
    }

    // print RC MAPPING
    for (i = 0; i < mcfg.rc_channel_count; i++)
        buf[mcfg.rcmap[i]] = rcChannelLetters[i];
    buf[i] = '\0';
    printf("map %s\r\n", buf);

    // print settings
    for (i = 0; i < VALUE_COUNT; i++) {
        setval = &valueTable[i];
        printf("set %s = ", valueTable[i].name);
        cliPrintVar(setval, 0);
        cliPrint("\r\n");
    }
}
Example #10
0
static int parseOptions(int argc, char **argv) {
    int i;

    for (i = 1; i < argc; i++) {
        int lastarg = i==argc-1;

        if (!strcmp(argv[i],"-h") && !lastarg) {
            sdsfree(config.hostip);
            config.hostip = sdsnew(argv[++i]);
        } else if (!strcmp(argv[i],"-h") && lastarg) {
            usage();
        } else if (!strcmp(argv[i],"--help")) {
            usage();
        } else if (!strcmp(argv[i],"-x")) {
            config.stdinarg = 1;
        } else if (!strcmp(argv[i],"-p") && !lastarg) {
            config.hostport = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-s") && !lastarg) {
            config.hostsocket = argv[++i];
        } else if (!strcmp(argv[i],"-r") && !lastarg) {
            config.repeat = strtoll(argv[++i],NULL,10);
        } else if (!strcmp(argv[i],"-i") && !lastarg) {
            double seconds = atof(argv[++i]);
            config.interval = seconds*1000000;
        } else if (!strcmp(argv[i],"-n") && !lastarg) {
            config.dbnum = atoi(argv[++i]);
        } else if (!strcmp(argv[i],"-a") && !lastarg) {
            config.auth = argv[++i];
        } else if (!strcmp(argv[i],"--raw")) {
            config.output = OUTPUT_RAW;
        } else if (!strcmp(argv[i],"--csv")) {
            config.output = OUTPUT_CSV;
        } else if (!strcmp(argv[i],"--latency")) {
            config.latency_mode = 1;
        } else if (!strcmp(argv[i],"--latency-history")) {
            config.latency_mode = 1;
            config.latency_history = 1;
        } else if (!strcmp(argv[i],"--slave")) {
            config.slave_mode = 1;
        } else if (!strcmp(argv[i],"--stat")) {
            config.stat_mode = 1;
        } else if (!strcmp(argv[i],"--rdb") && !lastarg) {
            config.getrdb_mode = 1;
            config.rdb_filename = argv[++i];
        } else if (!strcmp(argv[i],"--pipe")) {
            config.pipe_mode = 1;
        } else if (!strcmp(argv[i],"--bigkeys")) {
            config.bigkeys = 1;
        } else if (!strcmp(argv[i],"--eval") && !lastarg) {
            config.eval = argv[++i];
        } else if (!strcmp(argv[i],"-c")) {
            config.cluster_mode = 1;
        } else if (!strcmp(argv[i],"-d") && !lastarg) {
            sdsfree(config.mb_delim);
            config.mb_delim = sdsnew(argv[++i]);
        } else if (!strcmp(argv[i],"-v") || !strcmp(argv[i], "--version")) {
            sds version = cliVersion();
            printf("redis-cli %s\n", version);
            sdsfree(version);
            exit(0);
        } else {
            if (argv[i][0] == '-') {
                fprintf(stderr,
                    "Unrecognized option or bad number of args for: '%s'\n",
                    argv[i]);
                exit(1);
            } else {
                /* Likely the command name, stop here. */
                break;
            }
        }
    }
    return i;
}