Skip to content

Commit

Permalink
ssdb-cli supports command history
Browse files Browse the repository at this point in the history
  • Loading branch information
ideawu committed Apr 24, 2018
1 parent 15ffcdc commit ac276ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* 1.9.6
* New features:
- ssdb-cli supports command history(2018-04-24)
- Log slow query with WARN level(2017-11-08)
- Upgrade leveldb to version 1.20, fix MANIFEST file too large issue(2017-09-25)
* Incompatible changes:
Expand Down
13 changes: 13 additions & 0 deletions tools/ssdb-cli.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ sys.path.append('../api/python');
sys.path.append('/usr/local/ssdb/api/python');
import SSDB.*;

function save_cli_history(histfile){
readline.set_history_length(1000);
readline.write_history_file(histfile);
sys.stderr.write('\n');
}

try{
import readline;
import atexit;
histfile = '/tmp/ssdb-cli.history';
if(os.path.isfile(histfile)){
readline.read_history_file(histfile);
}
atexit.register(save_cli_history, histfile);
}catch(Exception e){
sys.stderr.write(str(e) + '\n');
}

escape_data = false;
Expand Down

0 comments on commit ac276ed

Please sign in to comment.