Skip to content

Instantly share code, notes, and snippets.

@MeLlamoPablo
Created August 12, 2017 15:12
Show Gist options
  • Save MeLlamoPablo/5c5272c23583e3c39085bda6c330ec94 to your computer and use it in GitHub Desktop.
Save MeLlamoPablo/5c5272c23583e3c39085bda6c330ec94 to your computer and use it in GitHub Desktop.
Converts a redis url to the corresponding redis-cli command
#!/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