Class: StackAgent::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/stack-agent/cli.rb

Instance Method Summary collapse

Instance Method Details

#cliObject



46
47
48
49
# File 'lib/stack-agent/cli.rb', line 46

def cli
  ARGV.clear
  IRB.start
end

#register(app_token = nil, name = nil, uri = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stack-agent/cli.rb', line 8

def register(app_token = nil, name = nil, uri = nil)

  StackAgent.configure do |c|
    c.app_token = app_token
    c.name = name
    c.uri = uri
  end

  if id = StackAgent::Instance.new().register
    puts "Registered as stack #{id}"
  end
end

#stacks(app_token) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/stack-agent/cli.rb', line 32

def stacks(app_token)
  StackAgent.configure do |c|
    c.app_token = app_token
  end

  stacks = StackAgent::Instance.stacks

  puts "Stacks"
  stacks.each do |stack|
    puts "#{stack['id'].ljust(30)} #{stack['name'].ljust(30)} #{stack['uri']}"
  end
end

#unregister(app_token, instance_token) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/stack-agent/cli.rb', line 22

def unregister(app_token, instance_token)
  StackAgent.configure do |c|
    c.app_token = app_token
  end

  StackAgent::Instance.new(instance_token).unregister
  puts "Unregistered stack"
end