class Pytty::Client::Cli::RmCommand

Public Instance Methods

execute() click to toggle source
# 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