Class: AudioAddict::Commands::ConfigCmd
- Inherits:
-
Base
- Object
- MisterBin::Command
- Base
- AudioAddict::Commands::ConfigCmd
show all
- Defined in:
- lib/audio_addict/commands/config.rb
Instance Method Summary
collapse
Methods inherited from Base
#current_channel, #current_network, #needs, #prompt, #radio, #require_premium_account
Instance Method Details
#check_command ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/audio_addict/commands/config.rb', line 79
def check_command
errors = verify_and_show_keys required_keys, critical: true
warnings = verify_and_show_keys optional_keys
say "Done. #{errors} errors, #{warnings} warnings."
errors.positive? ? 1 : 0
end
|
#del_command ⇒ Object
50
51
52
53
54
55
|
# File 'lib/audio_addict/commands/config.rb', line 50
def del_command
key = args['KEY'].to_sym
Config.delete key
Config.save
say 'g`Deleted`'
end
|
#edit_command ⇒ Object
66
67
68
69
|
# File 'lib/audio_addict/commands/config.rb', line 66
def edit_command
editor = ENV['EDITOR'] || 'vi'
system "#{editor} #{Config.path}"
end
|
#get_command ⇒ Object
36
37
38
39
40
|
# File 'lib/audio_addict/commands/config.rb', line 36
def get_command
key = args['KEY'].to_sym
value = Config.properties[key]
say value ? "g`#{value}`" : 'r`<Unset>`'
end
|
#guide_command ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/audio_addict/commands/config.rb', line 71
def guide_command
key_guide.each do |key, value|
say "g`#{key}`"
say word_wrap " #{value}"
say ''
end
end
|
#set_command ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/audio_addict/commands/config.rb', line 42
def set_command
key = args['KEY'].to_sym
value = args['VALUE']
Config.properties[key] = value
Config.save
say "g`#{key}=#{value}`"
end
|
#show_command ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/audio_addict/commands/config.rb', line 57
def show_command
say "mu`# #{Config.path}`"
if File.exist? Config.path
puts File.read Config.path
else
say 'r`File Not Found`'
end
end
|