Class: PortalModule::Command::Config

Inherits:
Thor
  • Object
show all
Defined in:
lib/portal_module/command/config.rb

Defined Under Namespace

Classes: Add, Del, Show

Instance Method Summary collapse

Instance Method Details

#defenv(envname = nil) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/portal_module/command/config.rb', line 266

def defenv(envname=nil)
  if envname.nil?
    with_loaded_config do
      say "default environment: #{PortalModule.configuration.default_environment}"
    end
    return
  end

  with_loaded_config(true) do
    if PortalModule.configuration.base_urls.key? envname.to_sym
      PortalModule.configuration.default_environment = envname.to_sym
    else
      say "argument error: environment '#{envname}' has not been configured", :red
    end
  end
end

#download_dir(dir = nil) ⇒ Object



293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/portal_module/command/config.rb', line 293

def download_dir(dir=nil)
  if dir.nil?
    with_loaded_config do
      say "download dir: #{PortalModule.configuration.download_dir}"
    end
    return
  end

  with_loaded_config(true) do
    PortalModule.configuration.download_dir = dir
  end
end

#init(filedir = nil) ⇒ Object



221
222
223
224
# File 'lib/portal_module/command/config.rb', line 221

def init(filedir = nil)
  outpath = PortalModule.save_configuration filedir
  say("configuration written to #{outpath.to_s}", :green) unless options[:quiet]
end

#timeout(seconds = nil) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/portal_module/command/config.rb', line 239

def timeout(seconds=nil)
  if seconds.nil?
    with_loaded_config do
      say "browser timeout: #{PortalModule.configuration.browser_timeout}"
    end
  else
    seconds = Integer(seconds)
    with_loaded_config(true) do
      PortalModule.configuration.browser_timeout = seconds
    end
  end
rescue ArgumentError => e
  say 'argument error: seconds must be an integer', :red
end