Class: Boxen::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/boxen/cli.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, flags) ⇒ CLI

Returns a new instance of CLI.



14
15
16
17
18
# File 'lib/boxen/cli.rb', line 14

def initialize(config, flags)
  @config = config
  @flags  = flags
  @runner = Boxen::Runner.new(@config, @flags)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/boxen/cli.rb', line 10

def config
  @config
end

#flagsObject (readonly)

Returns the value of attribute flags.



11
12
13
# File 'lib/boxen/cli.rb', line 11

def flags
  @flags
end

#runnerObject (readonly)

Returns the value of attribute runner.



12
13
14
# File 'lib/boxen/cli.rb', line 12

def runner
  @runner
end

Class Method Details

.run(*args) ⇒ Object

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



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
# 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

  # Run the preflight checks.

  Boxen::Preflight.run config

  # Save the config for Puppet (and next time).

  Boxen::Config.save config

  # Make the magic happen.

  status = Boxen::CLI.new(config, flags).run

  # Run the postflight checks.

  Boxen::Postflight.run config if status.success?

  # Return Puppet's exit status.

  return status.code
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
# File 'lib/boxen/cli.rb', line 20

def run
  if flags.help?
    puts flags
    exit
  end

  runner.run
end