diff --git a/lib/boxen.rb b/lib/boxen.rb index e722465..bc84e33 100644 --- a/lib/boxen.rb +++ b/lib/boxen.rb @@ -1,3 +1,6 @@ +require "boxen/config" +require "boxen/flags" + module Boxen # Is Boxen active? @@ -6,6 +9,40 @@ module Boxen ENV.include? "BOXEN_HOME" end + # Run Boxen by wiring together the command-line flags, config, + # preflights, Puppet execution, and postflights. Returns Puppet's + # exit code. + + def self.run *args + config = Boxen::Config.load + flags = Boxen::Flags.new args + + # Apply command-line flags to the config in case we're changing or + # overriding anything. + + flags.apply config + + # Run the preflight checks. + + #Boxen::Preflight.run config + + # Save the config for Puppet (and next time). + + #Boxen::Config.save config + + # Make the magic happen. + + code = 0#Boxen::CLI.new(config, flags).run + + # Run the postflight checks. + + #Boxen::Postflight.run config + + p :config => config + + return code + end + # Run `args` as a system command with sudo if necessary. def self.sudo *args diff --git a/lib/boxen/flags.rb b/lib/boxen/flags.rb index 01c304b..06c9a42 100644 --- a/lib/boxen/flags.rb +++ b/lib/boxen/flags.rb @@ -94,7 +94,7 @@ module Boxen end end - parse args + parse args.flatten.compact end # Apply these flags to `config`. Returns `config`.