Sha256: 409e5a1e8e229354783050087d5d3312bed94e0633574809acfa370e1889a9c5

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

require_relative 'command_factory'

module Dockerun
  module Cli
    class DSLProxy
      include DSL
    end

    class DeleteContainer

      def initialize
        @proxy = DSLProxy.new
      end

      def start(root)
        @proxy.set_exec_root(root)
        begin
          pmt.puts " Dockerun version #{Dockerun::VERSION}".yellow
          pmt.puts " Operational : Delete Container"
          delete_container
        rescue TTY::Reader::InputInterrupt
        end
      end

      def delete_container
        selSpec = CliEngine.select_spec(@proxy.exec_root)
        cont = File.read(selSpec)
        @proxy.set_dry_run_mode
        @proxy.instance_eval(cont)

        skip = pmt.no?(" Delete container named '#{@proxy.container_name}'?")
        if not skip
          cf.stop_container(@proxy.container_name).run
          res = cf.delete_container(@proxy.container_name).run
          if res.success?
            pmt.puts " Container '#{@proxy.container_name}' deleted".green
          else
            pmt.puts " Container '#{@proxy.container_name}' deletion failed. Error was : #{res.err_lines.join("\n")}".red
          end
        else
          pmt.puts " Container deletion of name '#{@proxy.container_name}' aborted.".yellow
        end
      end

      def pmt
        CliEngine.pmt
      end

      def cf
        if @_cf.nil?
          @_cf = CommandFactory.new
        end
        @_cf
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dockerun-0.4.2 lib/dockerun/cli/delete_container.rb
dockerun-0.4.1 lib/dockerun/cli/delete_container.rb