Class: Pytty::Client::Cli::RmCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/pytty/client/cli/rm_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pytty/client/cli/rm_command.rb', line 14

def execute
  ids = if all?
    process_yield_jsons = Async.run do
      Pytty::Client::Api::Ps.run
    end.wait
    process_yield_jsons.map do |json|
      json.fetch("id")
    end
  else
    id_list
  end

  Async.run do
    for id in ids do
      response, body = Pytty::Client::Api::Rm.run id: id

      if response.status == 200
        puts id
      else
        puts response.read
        exit 1
      end
    end
  end
end