Sha256: 7d977a0407fa78981aa0b6c9186b4393366633c29558238ed8114c1fd3bbbf6c

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

#!/usr/bin/env ruby

require 'tty/prompt'
require_relative '../lib/dockerun'

if ARGV.length == 0
  puts "dockerun version #{Dockerun::VERSION}"
  puts Dockerun::Command::Dockerun.new.help

else
  pmt = TTY::Prompt.new

  cmd = Dockerun::Command::Dockerun.new 
  res = cmd.parse(ARGV).params.to_h
  case res[:command].downcase
  when "init"
    initCmd = Dockerun::Command::Init.new
    argv = ARGV[1..-1]
    res2 = initCmd.parse(argv).run do |ops, val|
      case ops
      when :multiple_templates_detected
        pmt.select("There are multiple templates available. Please select one of the template : ") do |m|
          val.each do |v|
            m.choice v, v
          end
        end
      end
    end

    STDOUT.puts "\nDockerfile written to '#{res2}'\n\n"

  when "run", "r"

    begin
      runCmd = Dockerun::Command::Run.new
      argv = ARGV[1..-1]
      runCmd.parse(argv).run
    rescue TTY::Reader::InputInterrupt
    end


  when "run-new-container", "rnc"

    begin
      runCmd = Dockerun::Command::RunNewContainer.new
      argv = ARGV[1..-1]
      runCmd.parse(argv).run
    rescue TTY::Reader::InputInterrupt
    end


  when "run-new-image", "rni"

    begin
      runCmd = Dockerun::Command::RunNewImage.new
      argv = ARGV[1..-1]
      runCmd.parse(argv).run
    rescue TTY::Reader::InputInterrupt
    end


  when "rmi", "remove-image"
    begin
      riCmd = Dockerun::Command::ResetImage.new
      argv = ARGV[1..-1]
      riCmd.parse(argv).run
    rescue TTY::Reader::InputInterrupt
    end


  when "remove-container","rmc"
    # remove container
    begin
      riCmd = Dockerun::Command::RemoveContainer.new
      argv = ARGV[1..-1]
      riCmd.parse(argv).run
    rescue TTY::Reader::InputInterrupt
    end


  else
    STDERR.puts "Unknown command '#{res[:command]}'"
    STDOUT.puts cmd.help
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dockerun-0.1.14 exe/dockerun