Class: Docker::Cli::Operations::RunKeep
- Inherits:
-
Object
- Object
- Docker::Cli::Operations::RunKeep
- Includes:
- TR::ArgUtils
- Defined in:
- lib/docker/cli/operations/run_keep.rb
Instance Method Summary collapse
- #capture_command(a) ⇒ Object
- #capture_container_name(a) ⇒ Object
- #capture_image(a) ⇒ Object
-
#initialize ⇒ RunKeep
constructor
A new instance of RunKeep.
-
#run ⇒ Object
Just run with image name on command line.
- #set_use_same_user(bol) ⇒ Object
Constructor Details
#initialize ⇒ RunKeep
Returns a new instance of RunKeep.
35 36 37 38 39 40 |
# File 'lib/docker/cli/operations/run_keep.rb', line 35 def initialize @match_user = false #TR::RTUtils.on_linux? # leave this blank as the image may have already # set an entry program @cmd = "" end |
Instance Method Details
#capture_command(a) ⇒ Object
48 49 50 51 |
# File 'lib/docker/cli/operations/run_keep.rb', line 48 def capture_command(a) logger.debug "Capturing command : #{a}" @cmd = a end |
#capture_container_name(a) ⇒ Object
53 54 55 |
# File 'lib/docker/cli/operations/run_keep.rb', line 53 def capture_container_name(a) @contName = a end |
#capture_image(a) ⇒ Object
42 43 44 45 46 |
# File 'lib/docker/cli/operations/run_keep.rb', line 42 def capture_image(a) @fullArgv = a @dimage = a.first [true, a[1..-1]] end |
#run ⇒ Object
Just run with image name on command line
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/docker/cli/operations/run_keep.rb', line 62 def run if Docker::Cli::DockerRunLog.instance.has_existing_container?(@dimage) pmt = TTY::Prompt.new begin eCont = pmt.select(" System found there were some container already exist on this image.\n Do you want to reuse the existing container? ") do |m| DockerContainer.containers_of_image_from_history(@dimage).each do |c, name| m.choice name, c end m.choice "Run new container", :new_cont m.choice "Quit", :quit end case eCont when :new_cont run_new when :quit STDOUT.puts " Have a nice day " else cont = DockerContainer.new(eCont) cont.start if not cont.is_running? cont.attach end rescue TTY::Reader::InputInterrupt end else run_new end end |
#set_use_same_user(bol) ⇒ Object
57 58 59 |
# File 'lib/docker/cli/operations/run_keep.rb', line 57 def set_use_same_user(bol) @match_user = bol end |