Class: RemoteEnv

Inherits:
Thor
  • Object
show all
Defined in:
lib/negroku/cli.rb

Instance Method Summary collapse

Instance Method Details

#add(key = nil, value = nil) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/negroku/cli.rb', line 167

def add(key=nil, value=nil)

  # Check if the paramenter were sent in the call
  # Ask for the value if only the key was sent
  if !key.nil? && value.nil?
    value = ask("Please enter the value for #{key}:")
  # If nothing was sent
  elsif key.nil? && value.nil?
    # Check if the .rbenv-vars file exists and offer get the info from there
    if File.exist?(".rbenv-vars") && (agree "Do you want to add variables from your local .rbenv-vars file [y/n]", true)
      choose do |menu|
        menu.prompt = "Please choose variable you want to add?".bright()
        menu.select_by = :index

        File.readlines(".rbenv-vars").each do |line|
          menu.choice(line.gsub("\n","")) do |command|
            key = command.split("=")[0]
            value = command.split("=")[1]
          end
        end
      end
    else
      key = ask("Please enter the variable key:")
      value = ask("Please enter the value for #{key}:")
    end
  end

  %x(cap #{options[:stage]} rbenv:vars:add -s key=#{key} -s value=#{value})
end

#showObject



161
162
163
# File 'lib/negroku/cli.rb', line 161

def show
  %x(cap #{options[:stage]} rbenv:vars:show)
end