11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/vagrant-pushbullet/command.rb', line 11
def execute
config_file = ::VagrantPlugins::Pushbullet.config_file
if config_file.exist?
@env.ui.warn("Welcome to the Pushbullet Setup Guide")
guide = "This command helps you configure Pushbullet via it's config file: \#{config_file}\n\nTo limit notifications to specific devices:\n - If your token is correct you will see your devices below. \n - Add/remove device id's from the list shown below to: '\#{config_file}'. \nTo notify all devices:\n - Leave the DEVICES variable empty in your config file.\n"
@env.ui.info(guide)
require config_file
wb_client = get_washbullet_client(PushbulletConfig::TOKEN,config_file)
return if wb_client == nil
enabled_devices = PushbulletConfig::DEVICES
devices = wb_client.devices.body["devices"]
msg = []
devices.each { |device|
if device["active"]
devices = PushbulletConfig::DEVICES
enabled = "\e[32m Enabled"
disabled = "\e[31m Disabled"
enabled_theme = enabled_devices.include?(device['iden'])? enabled : disabled
enabled_theme = enabled if enabled_devices.size == 0
msg << " #{enabled_theme}: '#{device['nickname']}' id: #{device['iden']} \e[0m"
end
}
msg = msg.join("\n")
@env.ui.info(msg)
else
::VagrantPlugins::Pushbullet.write_default_key
@env.ui.error("Please put your pushbullet token from http://pushbullet.com/account into this file: #{config_file}.
\n ---- Then run this command again to limit pushes to specific devices-----")
end
end
|