Class: Unipept::Commands::Config

Inherits:
Cri::CommandRunner
  • Object
show all
Defined in:
lib/commands/unipept/config.rb

Instance Method Summary collapse

Instance Method Details

#configObject



16
17
18
# File 'lib/commands/unipept/config.rb', line 16

def config
  @config ||= Unipept::Configuration.new
end

#get_config(key) ⇒ Object



25
26
27
# File 'lib/commands/unipept/config.rb', line 25

def get_config(key)
  config[key]
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/commands/unipept/config.rb', line 3

def run
  abort command.help if arguments.empty? || arguments.size > 2

  key, value = *arguments

  if arguments.size == 2
    set_config(key, value)
    puts "#{key} was set to #{value}"
  else
    puts get_config(key)
  end
end

#set_config(key, value) ⇒ Object



20
21
22
23
# File 'lib/commands/unipept/config.rb', line 20

def set_config(key, value)
  config[key] = value
  config.save
end