Ninety-nine Pitchers of Malt
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    pretty-redispublic

    pretty-redis

    pretty-redis is a cli client for redis, which is beautiful and very simple.

    $ npm i -g pretty-redis

    MPM

    screencast

    pretty-redis@0.1.0-alpha
     
    $ pretty-redis -h 127.0.0.1 -p 6379
     
    --help, -h  redis host name
    --port, -p  redis port number
    --auth, -a  redis auth key
    --plugin  Node.js module name or file path

    Usage

    You can use pretty-redis as redis-cli in most cases:

     › keys *
     › set key value
     › get key

    It will only prettify json format. If you want to prettify other language/type, you can specify the language/type by using --lang option:

     › get html --lang=html

    It's already better then redis-cli but not pretty enough. So use highlight (alias: hl, hicat) filter to make it even better:

     › get html --lang=html | hl

    The list of supported options and filters is available in wiki.

    REPL

     › keys * --repl
     js › var fs = require('fs');
     js › // `data` - redis result
     js ›
     js › data = data.map(/* do something */);
     js ›
     js › var content = JSON.stringify(data);
     js › fs.writeFileSync('./data.json', content);

    Node.js

    The bare minimum for using pretty-redis on Node.js is requiring the module and create a PrettyRedis instance and calling #exec(command) to execute a command:

    var PrettyRedis = require('pretty-redis');
    var client = new PrettyRedis(); // connect to localhost:6379
     
    client.exec('keys *')
      .then(function (ctx) {
        // success
      }, function (err) {
        // field
      });

    Use plugins

    pretty-redis provides several plugins.

    var plugins = PrettyRedis.plugins;
     
    client.use(plugins.keys());
    client.use(plugins.jsonPrettify());
    // and so on

    Custom filter

    client.use(function (next) {
      if (!this.hasFilter('your-filter')) {
        return next();
      }
      // do something here
      next();
    });

    License

    (The MIT License)

    Keywords

    none

    install

    npm i pretty-redis

    Downloadsweekly downloads

    1

    version

    0.1.2

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar