Class: Coffee::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/coffee/cli.rb

Instance Method Summary collapse

Instance Method Details

#config(url) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/coffee/cli.rb', line 28

def config(url)
  puts "Configuring..."
  config = JSON.parse(HTTParty.get(File.join(url, "/coffee/config")).parsed_response)
  if ["login", "password", "host"].any? {|k| config.key?(k)}
    File.open(Coffee::Config.path, 'w') {|f| f.write config.to_yaml }
    puts "Success! Saving config in #{Coffee::Config.path.inspect}"
  else
    puts "Invalid response"
  end
end

#message(content) ⇒ Object



23
24
25
# File 'lib/coffee/cli.rb', line 23

def message(content)
  Coffee::Remote.message(content)
end

#offObject



12
13
14
15
# File 'lib/coffee/cli.rb', line 12

def off
  Coffee::Remote.off
  Coffee::Remote.print_status
end

#onObject



6
7
8
9
# File 'lib/coffee/cli.rb', line 6

def on
  Coffee::Remote.on
  Coffee::Remote.print_status
end

#statusObject



18
19
20
# File 'lib/coffee/cli.rb', line 18

def status
  Coffee::Remote.print_status
end