Class: Bender::CLI

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

Instance Method Summary collapse

Constructor Details

#initialize(args = [], opts = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bender/cli.rb', line 10

def initialize(args = [], opts = {}, config = {})
  super(args, opts, config)

  if !File.exists?(options[:config])
    puts "Cannot find #{options[:config]}."
    exit
  end

  config_options = YAML.load_file(options[:config]).deep_symbolize_keys
  @options = @options.symbolize_keys.merge(config_options)
end

Instance Method Details

#publishObject



43
44
45
46
47
48
49
50
51
# File 'lib/bender/cli.rb', line 43

def publish
  load_enviroment(options[:require])
  opts = @options.symbolize_keys.slice(:timeout, :interval, :daemon, :pid_file)
  Bender::Client.new(options[:hostname] || Socket.gethostname, @options).publish(
    options[:watcher],
    options[:message],
    options[:ack]
  )
end

#startObject



31
32
33
34
35
# File 'lib/bender/cli.rb', line 31

def start
  load_enviroment(options[:require])
  opts = @options.symbolize_keys.slice(:timeout, :interval, :daemon, :pid_file)
  Bender::Client.new(options[:hostname] || Socket.gethostname, @options).start_watchers
end