Module: JamesBond::Core

Defined in:
lib/james_bond/core.rb,
lib/james_bond/core/config.rb,
lib/james_bond/core/command.rb,
lib/james_bond/core/mission.rb,
lib/james_bond/core/help_mission.rb,
lib/james_bond/core/mission_pool.rb,
lib/james_bond/core/mission_loader.rb,
lib/james_bond/core/mission/undefined_variable_error.rb

Defined Under Namespace

Modules: Mission, MissionLoader Classes: Command, Config, HelpMission, MissionPool

Constant Summary collapse

DEFAULT_ENVIRONMENT =
"dev".freeze

Class Method Summary collapse

Class Method Details

.run_command(argv, env = DEFAULT_ENVIRONMENT) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/james_bond/core.rb', line 11

def run_command(argv, env=DEFAULT_ENVIRONMENT)
  config       = load_config
  mission_pool = MissionLoader.load_missions(config.missions)
  command      = Command.new(argv: argv, env:  env)
  command      = Command.new(argv: ["help"], env:  env) if command.empty?

  winning_mission = mission_pool.decide_mission(command)
  winning_mission.run_command(command: command, mission_pool: mission_pool)
end