class Boxen::CLI

Attributes

config[R]
flags[R]
runner[R]

Public Class Methods

new(config, flags) click to toggle source
# File lib/boxen/cli.rb, line 14
def initialize(config, flags)
  @config = config
  @flags  = flags
  @runner = Boxen::Runner.new(@config, @flags)
end
run(*args) click to toggle source

Run Boxen by wiring together the command-line flags, config, preflights, Puppet execution, and postflights. Returns Puppet's exit code.

# File lib/boxen/cli.rb, line 33
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

  if flags.run?
    # Run the preflight checks.
    Boxen::Preflight.run config

    # Save the config for Puppet (and next time).
    Boxen::Config.save config
  end

  # Make the magic happen.
  status = Boxen::CLI.new(config, flags).run

  if flags.run?
    # Run the postflight checks.
    Boxen::Postflight.run config if status.success?
  end

  # Return Puppet's exit status.
  return status.code
end

Public Instance Methods

run() click to toggle source
# File lib/boxen/cli.rb, line 20
def run
  if flags.help?
    puts flags
    exit
  end

  runner.run
end