Class: Geostats::Commands::Set
- Inherits:
-
Base
- Object
- Base
- Geostats::Commands::Set
show all
- Defined in:
- lib/geostats/commands/set.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #invoke
Instance Method Details
#before ⇒ Object
15
16
17
|
# File 'lib/geostats/commands/set.rb', line 15
def before
connect_database
end
|
#parse_args ⇒ Object
10
11
12
13
|
# File 'lib/geostats/commands/set.rb', line 10
def parse_args
raise UsageError if @args.length > 2
@key, @value = @args
end
|
#run ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/geostats/commands/set.rb', line 19
def run
if @key
if @value
Setting.set(@key, @value)
puts "#{@key} = #{@value}"
else
puts "#{@key} = #{Setting.get(@key) || "<null>"}"
end
else
Setting.all.each do |setting|
puts "#{setting.key} = #{setting.value || "<null>"}"
end
end
end
|
#usage ⇒ Object
4
5
6
7
8
|
# File 'lib/geostats/commands/set.rb', line 4
def usage
STDERR.puts "Usage: geostats set"
STDERR.puts " set <key>"
STDERR.puts " set <key> <value>"
end
|