Class: Notifyor::CLI

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

Instance Method Summary collapse

Instance Method Details

#check_notificationsObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/notifyor/cli.rb', line 48

def check_notifications
  connection = Notifyor::Remote::Connection.new
  begin
    connection.build_tunnel
    connection.build_redis_tunnel_connection
    connection.subscribe_to_redis
  rescue => e
    STDOUT.write "Could not establish SSH tunnel. Reason: #{e.message}"
  end
end

#parseObject



7
8
9
10
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
# File 'lib/notifyor/cli.rb', line 7

def parse
  # Default configuration.
  ENV['ssh_host'] = 'localhost'
  ENV['ssh_port'] = '22'
  ENV['ssh_tunnel_port'] = '2000'
  ENV['ssh_redis_port'] = '6379'

  ::OptionParser.new do |opts|
    opts.banner = 'Usage: notify_me [options]'

    opts.on('-v', '--version',
            'Show the current version of this gem') do
      puts "Notifyor Version: #{::Notifyor::VERSION}"; exit
    end

    opts.on('--ssh-host host', 'Provide the host address to your deployment/remote server') do |host|
      ENV['ssh_host'] = host
    end

    opts.on('--ssh-port port', 'Provide the ssh port for the deployment/remote server') do |port|
      ENV['ssh_port'] = port
    end

    opts.on('--ssh-user user', 'Provide the ssh user for the deployment/remote server') do |user|
      ENV['ssh_user'] = user
    end

    opts.on('--tunnel-port tunnel_port', 'Provide the ssh user for the deployment/remote server') do |tunnel_port|
      ENV['ssh_tunnel_port'] = tunnel_port
    end

    opts.on('--redis-port redis_port', 'Provide the ssh user for the deployment/remote server') do |redis_port|
      ENV['ssh_redis_port'] = redis_port
    end

    opts.on('--channel [channel]', 'Provide channel on which notifyor should listen.') do |channel|
      ENV['channel'] = channel
    end
  end.parse!
end