Module: CLI::Mastermind
- Extended by:
- Interface
- Defined in:
- lib/cli/mastermind.rb,
lib/cli/mastermind/plan.rb,
lib/cli/mastermind/errors.rb,
lib/cli/mastermind/loader.rb,
lib/cli/mastermind/version.rb,
lib/cli/mastermind/arg_parse.rb,
lib/cli/mastermind/configuration.rb,
lib/cli/mastermind/loader/planfile_loader.rb
Defined Under Namespace
Modules: Interface, VERSION Classes: ArgParse, Configuration, Error, Loader, Plan, UnsupportedFileTypeError
Class Attribute Summary collapse
-
.plans ⇒ Object
readonly
Returns the value of attribute plans.
Class Method Summary collapse
Methods included from Interface
ask, confirm, enable_ui, frame, select, spinner, titleize, ui_enabled?
Class Attribute Details
.plans ⇒ Object (readonly)
Returns the value of attribute plans.
15 16 17 |
# File 'lib/cli/mastermind.rb', line 15 def plans @plans end |
Class Method Details
.configuration ⇒ Object
17 18 19 |
# File 'lib/cli/mastermind.rb', line 17 def configuration @config end |
.execute(cli_args = ARGV) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cli/mastermind.rb', line 21 def execute(cli_args=ARGV) @arguments = ArgParse.new(cli_args) enable_ui if @arguments.display_ui? frame('Mastermind') do @config = spinner('Loading configuration') { Configuration.new } @plans = spinner('Loading plans') { @config.load_plans } @plan_stack = [] @selected_plan = nil while @arguments.has_additional_plan_names? plan_name = @arguments.get_next_plan_name @selected_plan = (@selected_plan || @plans)[plan_name] @plan_stack << titleize(plan_name) if @selected_plan.nil? puts "No plan found at #{@plan_stack.join('/')}" puts @arguments.parser exit 1 end end # Prevent the prompt from exploading if @selected_plan.nil? and @plans.count == 1 @selected_plan = @plans.values.first @plan_stack << titleize(@selected_plan.name) end while @selected_plan.nil? or @selected_plan.has_children? do_interactive_plan_selection @plan_stack << titleize(@selected_plan.name) end if !@arguments.ask? or confirm("Execute plan #{@plan_stack.join('/')}?") @selected_plan.call(@arguments.plan_arguments) else puts 'aborted!' end end end |
.gem_version ⇒ Object
4 5 6 |
# File 'lib/cli/mastermind/version.rb', line 4 def self.gem_version Gem::Version.new VERSION::STRING end |