Class: Usmu::Ui::Console
- Inherits:
-
Object
- Object
- Usmu::Ui::Console
- Defined in:
- lib/usmu/ui/console.rb
Overview
This is the CLI UI controller. This is initialised by the usmu binary to control the generation process.
Instance Attribute Summary collapse
-
#configuration ⇒ Usmu::Configuration
readonly
Do not access this till your command starts running, eg.
- #site_generator ⇒ Usmu::SiteGenerator readonly
Instance Method Summary collapse
-
#initialize(args) ⇒ Console
constructor
A new instance of Console.
- #load_configuration(config) ⇒ Object
Constructor Details
#initialize(args) ⇒ Console
Returns a new instance of Console.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/usmu/ui/console.rb', line 20 def initialize(args) @log = Logging.logger[self] @commander = Commander::Runner.new args @commander.program :version, Usmu::VERSION @commander.program :description, 'Static site generator powered by Tilt' @commander.program :int_message, 'Interrupt received, closing...' @commander.global_option('-v', '--verbose') { Usmu.verbose_logging } @commander.global_option('-q', '--quiet') { Usmu.quiet_logging } @commander.global_option('--log STRING', String) {|log| Usmu.add_file_logger(log) } @commander.global_option('--config STRING', String, &method(:load_configuration)) Usmu.plugins.load_plugins Usmu.plugins.invoke :commands, self, @commander @commander.default_command :generate @commander.run! end |
Instance Attribute Details
#configuration ⇒ Usmu::Configuration (readonly)
Do not access this till your command starts running, eg. in Hooks#commands, otherwise you may not get the right value for the configuration as option parsing may not have happened yet.
16 17 18 |
# File 'lib/usmu/ui/console.rb', line 16 def configuration @configuration || load_configuration('usmu.yml') end |
#site_generator ⇒ Usmu::SiteGenerator (readonly)
10 11 12 |
# File 'lib/usmu/ui/console.rb', line 10 def site_generator @site_generator end |
Instance Method Details
#load_configuration(config) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/usmu/ui/console.rb', line 40 def load_configuration(config) @log.info("Usmu v#{Usmu::VERSION}") @log.info('') if File.readable? config @configuration = Usmu::Configuration.from_file(config) @log.info("Configuration: #{config}") else @log.fatal("Unable to find configuration file at #{config}") raise end end |