Created
August 12, 2017 15:12
-
-
Save MeLlamoPablo/5c5272c23583e3c39085bda6c330ec94 to your computer and use it in GitHub Desktop.
Converts a redis url to the corresponding redis-cli command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
* Converts a redis url to the corresponding redis-cli command | |
*/ | |
const rl = require("readline").createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}) | |
rl.on("line", line => { | |
const regex = /redis:\/\/(.+):(.+)@(.+):(.+)/ | |
const matches = line.match(regex) | |
if (!matches) { return process.exit(0) } | |
const [ _, user, pass, host, port ] = matches | |
console.log(`redis-cli -h ${host} -p ${port} -a ${pass}`) | |
process.exit(0) | |
}) | |
setTimeout(() => process.exit(1), 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment