Class: Racker::CLI
- Inherits:
-
Object
- Object
- Racker::CLI
- Defined in:
- lib/racker/cli.rb
Overview
The CLI is a class responsible for handling the command line interface logic.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
13 14 15 |
# File 'lib/racker/cli.rb', line 13 def initialize(argv) @argv = argv end |
Instance Method Details
#execute! ⇒ Object
17 18 19 20 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 |
# File 'lib/racker/cli.rb', line 17 def execute! # Get the global logger log = Log4r::Logger['racker'] # Parse our arguments option_parser.parse!(@argv) # Set the logging level specified by the command line log.level = get_log4r_level([:log_level]) log.info("Log level set to: #{[:log_level]}") # Display the options if a minimum of 1 template and an output file is not provided if @argv.length < 2 puts option_parser Kernel.exit!(1) end # Set the output file to the last arg [:output] = @argv.pop log.debug("Output file set to: #{[:output]}") # Set the input files to the remaining args [:templates] = @argv # Run through Racker log.debug('Executing the Racker Processor...') Processor.new().execute! log.debug('Processing complete.') # Thats all folks! puts "Processing complete!" unless [:quiet] puts "Packer file generated: #{[:output]}" unless [:quiet] return 0 end |