Last active
August 29, 2015 14:00
-
-
Save nateborr/11308256 to your computer and use it in GitHub Desktop.
Open redis-cli for a Redis Cloud Heroku add-on
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
heroku_app_name = ARGV[0] | |
# For Heroku's new hk command line tool: | |
#url_matcher = %r{REDISCLOUD_URL=redis://rediscloud:(\w+)@([\w-.]+):(\d+)} | |
#env_string = `hk -a #{heroku_app_name} | grep REDISCLOUD_URL` | |
url_matcher = %r{REDISCLOUD_URL:\s*redis://rediscloud:(\w+)@([\w\-.]+):(\d+)} | |
env_string = `heroku config -a #{heroku_app_name} | grep REDISCLOUD_URL` | |
env_settings = env_string.split('\n') | |
match_data = url_matcher.match(env_settings[0]) | |
puts %{redis-cli -h #{match_data[2]} -p #{match_data[3]} -a #{match_data[1]}} |
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
#!/bin/bash | |
`ruby redis_cloud_heroku_cli.rb $1` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you add
#!/usr/bin/env ruby
as the first line of the .rb file, you can mark it executable and you won't need the shell command any more.
Also, I needed to escape the
-
on line 7 to solve anempty range in char class
error: