Class: AllImages::App
- Inherits:
-
Object
- Object
- AllImages::App
- Includes:
- FileUtils, Term::ANSIColor
- Defined in:
- lib/all_images/app.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ App
Returns a new instance of App.
11 12 13 14 15 |
# File 'lib/all_images/app.rb', line 11 def initialize(args) @args = args.dup @command = pick_command @commands = %w[ ls help run debug run_all ].sort end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/all_images/app.rb', line 17 def run @config = load_config or return 23 result = 0 case @command when 'ls' puts Array(@config['images']).map(&:first) when 'help' puts "Usage: #{File.basename($0)} #{@commands * ?|} IMAGE" else Array(@config['images']).each do |image, script| case @command when 'run_all' result |= run_image(image, script) when 'run_selected' image == @selected and result |= run_image(image, script) when 'debug_selected' image == @selected and result |= run_image(image, script, interactive: true) end if @config['fail_fast'] && result != 0 return 1 end end end result end |