Class: AudioAddict::Commands::StatusCmd

Inherits:
Base
  • Object
show all
Defined in:
lib/audio_addict/commands/status.rb

Instance Method Summary collapse

Methods inherited from Base

#current_channel, #current_network, #needs, #prompt, #radio, #require_premium_account

Instance Method Details

#keysObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/audio_addict/commands/status.rb', line 11

def keys
  {
    path: { 
      name: "Config Path", value: Config.path },

    email: { 
      name: "Email", command: 'login' },

    session_key: { 
      name: "Session Key", command: 'login', secret: true },

    listen_key: { 
      name: "Listen Key", command: 'login', secret: true },

    network: { 
      name: "Network", command: 'set' },

    channel: { 
      name: "Channel", command: 'set' },

    like_log: { 
      name: "Like Log", command: 'config like_log PATH' },
  }
end

#run(args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/audio_addict/commands/status.rb', line 36

def run(args)
  keys.each do |key, info|
    value = info[:value] || Config.properties[key]

    if value and !args['--unsafe'] and info[:secret]
      value = "***#{value[-4, 4]}" 
    end
    
    if value
      display_value = "!txtgrn!#{value}!txtrst!"
    else
      display_value = "!txtred!<Unset>!txtrst!"
      if info[:command]
        display_value = "#{display_value} - set with !txtpur!radio #{info[:command]}"
      end
    end

    say "!txtblu!#{info[:name].rjust 14}!txtrst! : #{display_value}"
  end

end