require 'eac_ruby_utils/console/docopt_runner' require 'eac_ruby_utils/console/speaker' module EacLauncher module Instances class RunnerHelper < ::EacRubyUtils::Console::DocoptRunner include ::EacRubyUtils::Console::Speaker def context @context ||= ::EacLauncher::Context.current end def find_instance(instance_name) context.instances.find { |i| i.name == instance_name } end def find_instance!(instance_path) instance = find_instance(instance_path) return instance if instance raise "Instance not found in \"#{instance_path}\"" end def instances if options['--all'] context.instances elsif options['--pending'] context.pending_instances else options[''].map { |p| find_instance!(p) } end end def instance_stereotypes(instance) instance.stereotypes.map(&:stereotype_name_in_color).join(', ') end def instance_label(instance) "#{instance.name} [#{instance_stereotypes(instance)}]" end end end end