Class: Scatter::Commands::Node::List

Inherits:
SubCommand show all
Defined in:
lib/scatter/commands/node/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(out, name = nil) ⇒ List

Returns a new instance of List.



5
6
7
8
# File 'lib/scatter/commands/node/list.rb', line 5

def initialize(out, name = nil)
  super(out)
  @name = name
end

Instance Method Details

#execute!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/scatter/commands/node/list.rb', line 10

def execute!
  nodes = if @name
    remote = Scatter::Config.find_remote(@name)
    raise CommandLineError, "Unknown remote #{@name}" unless remote
    remote.nodes
  else
    Scatter::Config.nodes
  end

  nodes.each do |node|
    @out.puts "#{node.remote.name}/#{node.name}"
  end
end