lib/dockdev.rb in dockdev-0.1.0 vs lib/dockdev.rb in dockdev-0.2.0

- old
+ new

@@ -1,10 +1,11 @@ # frozen_string_literal: true require 'teLogger' require 'toolrack' require 'docker/cli' +require 'colorize' require_relative "dockdev/version" require_relative 'dockdev/workspace' require_relative 'dockdev/image' @@ -34,10 +35,26 @@ img.new_container(cont.name, command: cmd) elsif wss.has_dockerfile? img.build(wss.dockerfile) img.new_container(cont.name, command: cmd) else - raise Error, "\n No image and no Dockerfile found to build the image found. Operation aborted. \n\n" + raise Error, "\n No image and no Dockerfile found to build the image found. Operation aborted. \n\n".red end end end + + def self.destroy(contName, opts = {}) + + cont = Container.new(contName) + if cont.has_container? + cont.stop if cont.running? + cont.destroy + end + + img = Image.new(contName) + if img.has_image? + img.destroy + end + + end + end