Class: Scatter::Commands::Node::Rm

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

Instance Method Summary collapse

Constructor Details

#initialize(out, remote, node = nil) ⇒ Rm

Returns a new instance of Rm.



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

def initialize(out, remote, node = nil)
  super(out)
  @remote, @node = remote, node
end

Instance Method Details

#execute!Object



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

def execute!
  node = if @node
    remote = Scatter::Config.find_remote(@remote)
    raise CommandLineError, "Unknown remote #{@remote}" unless remote
    remote.find_node(@node)
  else
    Scatter::Config.find_destination(@remote)
  end
  
  unless node
    dest = [@remote, @node].compact.join('/')
    raise CommandLineError, "Unknown node #{dest}"
  end

  node.remote.nodes.delete(node)
  Scatter::Config.save!
end