exe/dockerun in dockerun-0.1.15 vs exe/dockerun in dockerun-0.1.16
- old
+ new
@@ -1,7 +1,10 @@
#!/usr/bin/env ruby
+require 'toolrack'
+include TR::CondUtils
+
require 'tty/prompt'
require_relative '../lib/dockerun'
if ARGV.length == 0
puts "dockerun version #{Dockerun::VERSION}"
@@ -14,79 +17,88 @@
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
+ begin
+ 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
+
+ when :prompt_user_configurables
+ pmt.say "\n The following are the configurable items for the template '#{val[:template]}' : \n", color: :yellow
+ res = { }
+ val[:userFields].each do |k,v|
+ res[k] = pmt.ask("#{k.to_s.capitalize} : ") do |s|
+ s.required v[:required] if not_empty?(v[:required]) and is_bool?(v[:required])
+ s.value v[:default].to_s if not_empty?(v[:default])
+ end
+ end
+ res
end
end
+
+ STDOUT.puts "\nDockerfile written to '#{res2}'\n\n"
+ rescue TTY::Reader::InputInterrupt
+ pmt.say "\n\n Aborted\n", color: :yellow
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
+ pmt.say "\n\n Aborted\n", color: :yellow
end
when "run-new-container", "rnc"
begin
runCmd = Dockerun::Command::RunNewContainer.new
argv = ARGV[1..-1]
runCmd.parse(argv).run
rescue TTY::Reader::InputInterrupt
+ pmt.say "\n\n Aborted\n", color: :yellow
end
when "run-new-image", "rni"
begin
runCmd = Dockerun::Command::RunNewImage.new
argv = ARGV[1..-1]
runCmd.parse(argv).run
rescue TTY::Reader::InputInterrupt
+ pmt.say "\n\n Aborted\n", color: :yellow
end
- when "stop", "s"
- begin
- runCmd = Dockerun::Command::StopContainer.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
+ pmt.say "\n\n Aborted\n", color: :yellow
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
+ pmt.say "\n\n Aborted\n", color: :yellow
end
else
STDERR.puts "Unknown command '#{res[:command]}'"