require 'json'
if ARGV.empty?
puts "Please supply the Heroku app name. Example:"
puts "$ ruby json-env-variables-to-cli-params.rb my-awesome-app"
exit
end
heroku_app = ARGV[0]
begin
variables = `heroku config --app #{heroku_app} --json`
json_variables = JSON.parse(variables)
cli_cmd = ""
json_variables.each do |key, value|
cli_cmd << "\"#{key}=#{value}\" "
end
puts cli_cmd
rescue
end
1) Download the script below
2) Run it with the Heroku app name as the command argument. Example:
```
$ ruby json-env-variables-to-cli-params.rb the-heroku-app-name
```
3) Copy the output
4) `cd` into a new Heroku app
5) Apply the config variable to new Heroku app. Example:
```
$ heroku config:set the-value-you-just-copied
```