Sha256: 6568d8ca96ce0c971735270af12bf199c3eab2a2db45118a1e2d28ee9d9aef5e

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module DokkuInstaller
  class Cli < Thor

    desc "config", "Display the app's environment variables"
    def config
      run_command "config #{app_name}"
    end

    desc "config:get KEY", "Display an environment variable value"
    def config_get(*args)
      run_command "config:get #{app_name} #{args.first}"
    end

    desc "config:set KEY1=VALUE1 [KEY2=VALUE2 ...]", "Set one or more environment variables"
    def config_set(*args)
      # FIXME: Requires root to send config values with spaces
      user = "dokku"

      args = args.map{|arg|
        key_value = arg.split("=")
        if key_value.length == 2
          user = "root" if key_value[1].index(" ")
          return_value  = "#{key_value[0]}="
          return_value += '\"'
          return_value += key_value[1].gsub(/"|'/, "")
          return_value += '\"'
          return_value
        else
          arg
        end
      }

      command  = "ssh #{user}@#{domain} "
      command += user == "root" ? "dokku " : ""
      command += "config:set #{app_name} #{args.join(' ')}"

      puts "Running #{command}..."
      exec(command)
    end

    desc "config:unset KEY1 [KEY2 ...]", "Unset one or more environment variables"
    def config_unset(*args)
      run_command "config:unset #{app_name} #{args.join(' ')}"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dokku-installer-cli-0.0.9.2 lib/dokku_installer/config.rb