Class: Circus::CLI

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

Constant Summary collapse

LOGGER =
StdoutLogger.new

Instance Method Summary collapse

Instance Method Details

#admit(name = nil, *apps) ⇒ Object



95
96
97
98
# File 'lib/circus/cli.rb', line 95

def admit(name = nil, *apps)
  tool = BoothTool.new(LOGGER, LocalConfig.new)
  exit 1 unless tool.admit(name, apps, options)
end

#alias(name, target) ⇒ Object



155
156
157
158
159
# File 'lib/circus/cli.rb', line 155

def alias(name, target)
  local_config = LocalConfig.new
  local_config.aliases[name] = target
  local_config.save!
end

#assembleObject



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

def assemble
  load!
  
  output_path = File.expand_path(options[:output])
  dev = options[:dev]

  @app.assemble!(output_path, LOGGER, dev)
  if options[:actstore]
    store = ActStoreClient.new(options[:actstore], LOGGER)
    @app.upload(output_path, store)
  end
end

#configure(target, name, config) ⇒ Object



147
148
149
150
151
152
# File 'lib/circus/cli.rb', line 147

def configure(target, name, config)
  connection = ConnectionBuilder.new(options).build(target)
  
  client = ClownClient.new(connection, LOGGER)
  client.configure(target, name, config).result
end

#connect(name, booth) ⇒ Object

method_option :jid, :required => true, :desc => ‘The deployer jid to connect as’ method_option :host, :required => true, :desc => ‘The XMPP host to connect to’ method_option :port, :type => :numeric, :default => 5222, :desc => ‘The XMPP port to connect to’ method_option :password, :required => true, :desc => ‘The XMPP user password’



86
87
88
89
90
91
# File 'lib/circus/cli.rb', line 86

def connect(name, booth)
  config = LocalConfig.new
  tool = BoothTool.new(LOGGER, config)
  tool.connect(name, booth, options)
  config.save!
end

#deploy(target, name, act) ⇒ Object

method_option :actstore, :required => true, :desc => ‘The store to retrieve the act from’ method_option :jid, :required => true, :desc => ‘The deployer jid to connect as’ method_option :host, :required => true, :desc => ‘The XMPP host to connect to’ method_option :port, :type => :numeric, :default => 5222, :desc => ‘The XMPP port to connect to’ method_option :password, :required => true, :desc => ‘The XMPP user password’



127
128
129
130
131
132
# File 'lib/circus/cli.rb', line 127

def deploy(target, name, act)
  connection = ConnectionBuilder.new(options).build(target)
  
  client = ClownClient.new(connection, LOGGER)
  client.deploy(target, name, act, options[:config]).result
end

#exec(target, act_name, *cmd_parts) ⇒ Object

method_option :jid, :required => true, :desc => ‘The deployer jid to connect as’ method_option :host, :required => true, :desc => ‘The XMPP host to connect to’ method_option :port, :type => :numeric, :default => 5222, :desc => ‘The XMPP port to connect to’ method_option :password, :required => true, :desc => ‘The XMPP user password’



105
106
107
108
109
110
111
# File 'lib/circus/cli.rb', line 105

def exec(target, act_name, *cmd_parts)
  cmd = cmd_parts.join(' ')
  
  connection = ConnectionBuilder.new(options).build(target)
  client = ClownClient.new(connection, LOGGER)
  exit 1 unless client.exec(target, act_name, cmd).result
end

#get_booth_key(booth) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/circus/cli.rb', line 67

def get_booth_key(booth)
  connection = ConnectionBuilder.new(options).build(booth)
  
  client = BoothClient.new(connection, LOGGER)
  key = client.get_ssh_key(booth).result
  puts "SSH key for: #{booth}"
  puts "  #{key}"
end

#goObject



25
26
27
28
# File 'lib/circus/cli.rb', line 25

def go
  load!
  @app.go!(LOGGER)
end

#pause(act_name) ⇒ Object



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

def pause(act_name)
  load!
  @app.pause(LOGGER, act_name)
end

#reset(target, act_name) ⇒ Object



114
115
116
117
118
# File 'lib/circus/cli.rb', line 114

def reset(target, act_name)
  connection = ConnectionBuilder.new(options).build(target)
  client = ClownClient.new(connection, LOGGER)
  exit 1 unless client.reset(target, act_name).result
end

#resume(act_name) ⇒ Object



37
38
39
40
# File 'lib/circus/cli.rb', line 37

def resume(act_name)
  load!
  @app.resume(LOGGER, act_name)
end

#undeploy(target, name) ⇒ Object

method_option :jid, :required => true, :desc => ‘The deployer jid to connect as’ method_option :host, :required => true, :desc => ‘The XMPP host to connect to’ method_option :port, :type => :numeric, :default => 5222, :desc => ‘The XMPP port to connect to’ method_option :password, :required => true, :desc => ‘The XMPP user password’



139
140
141
142
143
144
# File 'lib/circus/cli.rb', line 139

def undeploy(target, name)
  connection = ConnectionBuilder.new(options).build(target)
  
  client = ClownClient.new(connection, LOGGER)
  client.undeploy(target, name).result
end

#upload(fn) ⇒ Object



61
62
63
64
# File 'lib/circus/cli.rb', line 61

def upload(fn)
  store = ActStoreClient.new(options[:actstore], LOGGER)
  store.upload_act(fn)
end