Commit Graph

150 Commits

Author SHA1 Message Date
antirez
994c5b26dd redis-cli: support for --scan option. 2014-01-22 12:04:08 +01:00
Michel Martens
347ab78e90 Document the redis-cli --csv option. 2013-09-26 10:12:46 +02:00
antirez
2debce325b redis-cli: fix big keys search when the key no longer exist.
The code freed a reply object that was never created, resulting in a
segfault every time randomkey returned a key that was deleted before we
queried it for size.
2013-09-04 10:35:53 +02:00
Jan-Erik Rediger
1b696dc07c Wrap IPv6 in brackets in the prompt. 2013-07-11 17:47:55 +02:00
antirez
1135e9faa2 redis-cli: introduced --pipe-timeout.
When in --pipe mode, after all the data transfer to the server is
complete, now redis-cli waits at max the specified amount of
seconds (30 by default, use 0 to wait forever) without receiving any
reply at all from the server. After this time limit the operation is
aborted with an error.

That's related to issue #681.
2013-07-03 12:22:03 +02:00
antirez
fbb97c6b13 redis-cli --pipe: send final ECHO in a safer way.
If the protocol read from stdin happened to contain grabage (invalid
random chars), in the previous implementation it was possible to end
with something like:

dksfjdksjflskfjl*2\r\n$4\r\nECHO....

That is invalid as the *2 should start into a new line. Now we prefix
the ECHO with a CRLF that has no effects on the server but prevents this
issues most of the times.

Of course if the offending wrong sequence is something like:

$3248772349\r\n

No one is going to save us as Redis will wait for data in the context of
a big argument, so this fix does not cover all the cases.

This partially fixes issue #681.
2013-07-03 11:59:44 +02:00
antirez
f8ae70cf7c redis-cli: raise error on bad command line switch.
Previously redis-cli never tried to raise an error when an unrecognized
switch was encountered, as everything after the initial options is to be
transmitted to the server.

However this is too liberal, as there are no commands starting with "-".
So the new behavior is to produce an error if there is an unrecognized
switch starting with "-". This should not break past redis-cli usages
but should prevent broken options to be silently discarded.

As far the first token not starting with "-" is encountered, all the
rest is considered to be part of the command, so you cna still use
strings starting with "-" as values, like in:

    redis-cli --port 6380 set foo --my-value
2013-04-11 13:17:25 +02:00
antirez
0280c2f252 redis-cli: --latency-history mode implemented. 2013-04-11 13:11:41 +02:00
antirez
09aa55a334 redis-cli --stat, stolen from redis-tools.
Redis-tools is a connection of tools no longer mantained that was
intented as a way to economically make sense of Redis in the pre-vmware
sponsorship era. However there was a nice redis-stat utility, this
commit imports one of the functionalities of this tool here in redis-cli
as it seems to be pretty useful.

Usage: redis-cli --stat

The output is similar to vmstat in the format, but with Redis specific
stuff of course.

From the point of view of the monitored instance, only INFO is used in
order to grab data.
2013-03-22 17:54:32 +01:00
antirez
91d3b487e7 redis-cli --bigkeys: don't crash with empty DBs. 2013-03-12 09:58:00 +01:00
antirez
8c193af696 redis-cli: use sdsfreesplitres() instead of hand-coding it. 2013-03-06 12:38:32 +01:00
antirez
3b3974410e redis-cli: use keepalive socket option.
This should improve things in two ways:

1) Prevent timeouts caused by the execution of long commands.
2) Improve detection of real connection errors.

This is mostly effective only on Linux because of the bogus default
keepalive settings. In Linux we have OS-specific calls to set the
keepalive interval to reasonable values.
2013-03-04 11:14:32 +01:00
antirez
6b641f3aeb redis-cli: update prompt on cluster redirection. 2013-02-14 18:49:08 +01:00
antirez
88015b89a0 redis-cli --bigkeys output is now simpler to understand. 2013-01-21 19:15:58 +01:00
guiquanz
9d09ce3981 Fixed many typos. 2013-01-19 10:59:44 +01:00
Salvatore Sanfilippo
61dfc2e521 Merge pull request #887 from charsyam/redis-cli-prompt
redis-cli prompt bug fix
2013-01-19 01:32:28 -08:00
Salvatore Sanfilippo
74f137308e Merge pull request #895 from badboy/catch_con_error
redis-cli: always exit if connection fails.
2013-01-19 01:27:56 -08:00
Jan-Erik Rediger
59046a7373 Always exit if connection fails.
This avoids unnecessary core dumps. Fixes antirez/redis#894
2013-01-18 10:13:10 +01:00
Nathan Parry
1920cab3bc redis-cli --rdb fails if server sends a ping
Redis pings slaves in "pre-synchronization stage" with newlines. (See
https://github.com/antirez/redis/blob/2.6.9/src/replication.c#L814)
However, redis-cli does not expect this - it sees the newline as the end
of the bulk length line, and ends up returning 0 as bulk the length.
This manifests as the following when running redis-cli:

    $ ./src/redis-cli --rdb some_file
    SYNC sent to master, writing 0 bytes to 'some_file'
    Transfer finished with success.

With this commit, we just ignore leading newlines while reading the bulk
length line.

To reproduce the problem, load enough data into Redis so that the
preparation of the RDB snapshot takes long enough for a ping to occur
while redis-cli is waiting for the data.
2013-01-18 00:10:58 -05:00
charsyam
e396236651 redis-cli prompt bug fix 2013-01-16 17:20:54 -08:00
antirez
a0c24821e2 redis-cli: save an RDB dump from remote server to local file. 2013-01-16 19:44:37 +01:00
antirez
4dc1e0dd30 Fix overflow in mstime() in redis-cli and benchmark.
The problem does not exist in the Redis server implementation of mstime()
but is only limited to redis-cli and redis-benchmark.

Thix fixes issue #839.
2012-12-20 15:20:55 +01:00
antirez
4365e5b2d3 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
Steeve Lennmark
e9828cb6f7 Check that we have connection before enabling pipe mode 2012-07-15 14:35:02 +02:00
Ted Nyman
d665dd0865 Standardize punctuation in redis-cli help.
Right there is a mix of help entries ending with periods or
without periods. This standardizes the end of command as without
periods, which seems to be the general custom in most unix tools,
at least.
2012-06-12 22:35:00 -07:00
antirez
e9f0419c99 Added time.h include in redis-cli.
redis-cli.c uses the time() function to seed the PRNG, but time.h was
not included. This was not noticed since sys/time.h is included and was
enough in most systems (but not correct). With Ubuntu 12.04 GCC
generates a warning that made us aware of the issue.
2012-05-14 17:35:51 +02:00
antirez
ea66be6080 redis-cli pipe mode: handle EINTR properly as well so that SIGSTOP/SIGCONT are handled correctly. 2012-05-11 16:08:57 +02:00
antirez
f6bd9122c0 redis-cli pipe mode: handle EAGAIN while writing to socket. 2012-05-11 10:45:12 +02:00
antirez
088c508abc redis-cli --pipe for mass import. 2012-05-07 16:37:18 +02:00
antirez
e54fe9a79f A few compiler warnings suppressed. 2012-04-24 11:11:55 +02:00
antirez
5386f72d00 redis-cli --bigkeys output modified to be simpler to read.. 2012-04-18 20:53:37 +02:00
antirez
f26761aa10 redis-cli --bigkeys 2012-04-18 20:33:02 +02:00
antirez
0d44d50792 Suppress warnings compiling redis-cli with certain gcc versions. 2012-03-19 19:28:49 +01:00
antirez
60893c6cc6 redis-cli: CSV output added, used for the --slave mode. 2012-02-29 17:43:06 +01:00
antirez
b8283ab218 Initial implementation of redis-cli --slave support. 2012-02-29 17:10:21 +01:00
antirez
a5bd08487f Fix for issue #306, thanks to tchajed (on github) for the pull request. The original patch was reworked a bit. 2012-02-22 16:07:06 +01:00
antirez
4eb3b3e970 Redis-cli should accept help command even if there is no connection to the server. 2012-02-22 15:16:11 +01:00
antirez
e2f313899b redis-cli --eval implemented 2011-12-13 16:22:28 +01:00
antirez
db6a2e7f78 Fixed a memory leak in redis-cli.c 2011-10-28 17:43:04 +02:00
antirez
623131d408 Totally hackish and dirty, but working, support for Redis Cluster in redis-cli 2011-10-05 19:55:33 +02:00
Salvatore Sanfilippo
7c748c061e Merge pull request #97 from jvain/redis-cli
redis-cli segfaults with single numeric argument greater than zero
2011-09-21 13:32:24 -07:00
Juri M. Vainonen
aee7f99760 fixed a small bug that caused redis-cli to segfault when given single numeric parameter greater that zero. 2011-09-21 23:22:14 +03:00
antirez
96674b6d95 Fixed a bug in the average latency metering of redis-cli --latency 2011-09-15 19:33:24 +02:00
antirez
43071993e1 Implemented --latency in redis-cli 2011-09-15 19:28:00 +02:00
antirez
18f63d8d51 redis-cli: -i (interval) implemented, to wait the specified number of seconds (decimal digits are allowed) between commands. 2011-05-28 15:41:08 +02:00
antirez
442c748d84 redis-cli: Use the repetiton prefix after a reconnection. 2011-05-28 15:25:48 +02:00
antirez
4d19e3443c redis-cli in REPL mode is now able to send the same command multiple times, prefixing the command with a number as in "10 ping" 2011-05-28 15:13:55 +02:00
antirez
a45f9a1a1d redis-cli no longer aborts in repl-mode on error, and retries to reconncet with the server at every command issued if the state is not connected. Also the prompt shows the server we are connected to. 2011-05-28 15:04:12 +02:00
antirez
3cd12b5687 CLIENT LIST implemented 2011-04-21 15:38:02 +02:00
antirez
ecc9109434 Cluster branch merged to unstable. 2011-03-29 17:51:15 +02:00
Pieter Noordhuis
3f4eef215b Show database number in cli prompt when non-zero 2011-03-06 21:14:40 +01:00
Pieter Noordhuis
96e34b3ce1 Store SELECTed database for reconnect (issue #468) 2011-03-06 20:46:49 +01:00
Pieter Noordhuis
33753a732a Minor memory leak in redis-cli (issue #464) 2011-03-06 20:13:01 +01:00
Pieter Noordhuis
ca36b4ab31 Only save history when stdin is a tty (issue #465) 2011-03-06 20:02:33 +01:00
Pieter Noordhuis
8ce39260a4 Fix compiler warnings on Solaris 2010-12-23 11:26:11 +00:00
Pieter Noordhuis
28c07c7bf8 Specify multi-bulk delimiter via options 2010-12-15 16:02:07 +01:00
Pieter Noordhuis
65add0a311 Improved raw output mode
Raw output mode is selected by default when STDOUT is not a tty. For
ttys, raw output can be forced using the option "--raw".
2010-12-15 15:59:06 +01:00
Pieter Noordhuis
f18e059e82 Make redis-cli help a little better 2010-12-15 15:00:47 +01:00
Pieter Noordhuis
c392edf531 Show redis-cli version with repository information if present 2010-12-15 14:34:05 +01:00
antirez
bbac56c2f8 added support for ctrl-l and clear command into redis-cli. To clear the screen is a good idea from time to time :). Also linenoise updated to the current version to support this new feature. 2010-12-01 11:18:59 +01:00
antirez
ce260f736e minor merge conflicts merging cli-help branch fixed 2010-11-30 11:39:55 +01:00
Pieter Noordhuis
b2cc45bfbc Refactor and support help for command names with spaces 2010-11-29 20:26:32 +01:00
Pieter Noordhuis
41945ba6ae Use linenoise completion API from redis-cli 2010-11-29 19:27:36 +01:00
antirez
d8d528e992 quick and dirty fix for hiredis bug creating problem with the new redis-cli connect commmand. Also change prompt when redis-cli is not connected 2010-11-29 12:20:17 +01:00
antirez
efcf948c1a new redis-cli command connect 2010-11-29 12:17:55 +01:00
Pieter Noordhuis
a2a69d5803 Refactor help-related code into redis-cli.c 2010-11-28 21:37:19 +01:00
Pieter Noordhuis
2612e0521f Merge remote branch 'visionmedia/cli-help' into cli-help 2010-11-26 20:46:42 +01:00
Tj Holowaychuk
5397f2b596 Added redis-cli interactive help support
updated via commands.json in redis-doc repo. Currently
use `make src/help.h` to re-generate. The following
are valid from the REPL:

  help
  help [command]
  help [group]
  help groups

ex:

  help sort
  help hash
2010-11-16 05:50:26 -08:00
antirez
11fd0c422b now redis-cli is able to show the Git SHA1 in the version output 2010-11-08 16:26:02 +01:00
antirez
d9d8ccab93 make sure to flush stdout every line read in monitor mode, to play well with redirection to file 2010-11-08 16:14:15 +01:00
Pieter Noordhuis
339b9dc2d2 Put duration in parenthesis 2010-11-03 17:07:10 +01:00
Pieter Noordhuis
cfcd5d6d43 Add proper numbering for multi bulk replies in redis-cli 2010-11-03 17:03:54 +01:00
Pieter Noordhuis
7fc4ce13ed Use hiredis from redis-cli 2010-11-03 16:09:38 +01:00
antirez
0a546fc017 Merge remote branch 'pietern/unixsocket' 2010-11-02 23:47:52 +01:00
antirez
3ce014c766 redis-cli in interactive mode now prints the time elapsed of the operation performed took more than half a second. 2010-11-02 18:08:30 +01:00
Pieter Noordhuis
33aba595b0 Removed unused command flags 2010-10-17 17:31:40 +02:00
Pieter Noordhuis
b04ce2a35c Merge master with resolved conflict in src/redis-cli.c 2010-10-13 18:55:46 +02:00
antirez
fdc0bde935 minor typo fixed, reported by Thomas Bassetto 2010-10-07 12:49:14 +02:00
antirez
bc63407be6 redis-cli does no longer try to auto detect if it is used inside a pipe. To read last argument from stdandard input there is to use the -x option. This will make it playing better inside cron scripts and in general when stdin is hacked. 2010-09-09 16:38:10 +02:00
antirez
8079656a8e Now redis-cli replies to help showing some basic usage information (Issue 291) 2010-08-30 15:57:03 +02:00
antirez
93b2a7718e It is now possible to use authentication and DB selection options at the same time in redis-cli (Issue 298) 2010-08-30 15:36:13 +02:00
antirez
e0e1c19520 Fixed MONITOR mode and Issue 296 2010-08-30 11:51:45 +02:00
Pieter Noordhuis
b4b62c34db Use fstat to detect if stdin was redirected 2010-08-25 14:48:50 +02:00
Pieter Noordhuis
ae77016e57 Add a newline to tty output after every reply 2010-08-25 13:39:11 +02:00
Pieter Noordhuis
5d15b5207d Re-introduce the interactive field so we can reconnect in interactive mode 2010-08-25 13:09:22 +02:00
Pieter Noordhuis
4b93e5e267 Merge master and move argument splitting patch to sds.c 2010-08-25 13:08:43 +02:00
antirez
c0b3d42372 redis-cli now supports automatically reconnection in interactive mode 2010-08-24 18:39:34 +02:00
antirez
b37ca6edb1 Issue 179 fixed, now redis-cli is able to parse correctly multi bulk replies with elements that are errors 2010-08-24 18:08:09 +02:00
antirez
cbce517145 redis cli argument splitting is general and is now moved into the sds.c lib 2010-08-05 11:36:39 +02:00
Pieter Noordhuis
abb731e5b8 Deprecate starting interactive mode using the -i flag 2010-08-04 18:36:03 +02:00
Pieter Noordhuis
cf0c6b78f1 Set tty before going into interactive mode to get non-pretty output when
the commands are read from stdin.
2010-08-04 18:16:39 +02:00
Pieter Noordhuis
3a51bff035 Change output format for non-tty redis-cli execution 2010-08-04 17:46:56 +02:00
Pieter Noordhuis
123a10f7a5 Let the output mode depend on having a tty or not 2010-08-04 17:16:05 +02:00
Pieter Noordhuis
07242c0ccf Tests for redis-cli in non-interactive mode
Minor change in redis-cli output for the (multi-)bulk response but this
will be fixed in the next commit.
2010-08-04 17:02:13 +02:00
Pieter Noordhuis
0439d792c4 Add tests for quotation in an interactive redis-cli session
Patched redis-cli to abort on unexpected quotation. This caused
redis-cli to get into an infinite, memory-consuming loop.
2010-08-04 16:15:33 +02:00
Pieter Noordhuis
f2dd4769dd Tests for the interactive mode of redis-cli
Changed redis-cli to output the raw response for a bulk reply when it is
run in interactive mode instead of checking isatty.
2010-08-04 15:28:03 +02:00
Pieter Noordhuis
7e91f971f7 Add support for domain sockets to redis-cli 2010-08-01 23:06:00 +02:00
antirez
99628c1af8 redis-cli history saved across sessions 2010-07-07 18:44:53 +02:00
antirez
185cabda45 redis-cli is now able to report version information using -v 2010-07-06 19:17:09 +02:00
antirez
e2641e09cc redis.c split into many different C files.
networking related stuff moved into networking.c

moved more code

more work on layout of source code

SDS instantaneuos memory saving. By Pieter and Salvatore at VMware ;)

cleanly compiling again after the first split, now splitting it in more C files

moving more things around... work in progress

split replication code

splitting more

Sets split

Hash split

replication split

even more splitting

more splitting

minor change
2010-07-01 14:38:51 +02:00