| Class | Webgen::CommandParser |
| In: |
lib/webgen/cli.rb
|
| Parent: | CmdParse::CommandParser |
| VERBOSITY_UNUSED | = | -1 |
| config_file | [R] | |
| directory | [R] | |
| verbosity | [R] | |
| website | [R] |
# File lib/webgen/cli.rb, line 395
395: def initialize
396: super( true )
397: @directory = Dir.pwd
398: @verbosity = VERBOSITY_UNUSED
399:
400: self.program_name = "webgen"
401: self.program_version = Webgen::VERSION
402: self.options = CmdParse::OptionParserWrapper.new do |opts|
403: opts.separator "Global options:"
404: opts.on( "--directory DIR", "-d", String, "The website directory, if none specified, current directory is used." ) {|@directory|}
405: opts.on( "--verbosity LEVEL", "-V", Integer, "The verbosity level (0-3)" ) {|@verbosity|}
406: end
407:
408: # Run command
409: run = CmdParse::Command.new( 'run', false )
410: run.short_desc = "Runs webgen, ie. generates the HTML files"
411: run.description = CliUtils.format("\nWith no arguments, renders the whole site. If file names are " +
412: "specified (don't include the path/to/src/ part), only those are rendered." )
413: run.set_execution_block do |args|
414: @website.render( args )
415: end
416: self.add_command( run, true )
417:
418: self.add_command( CreateCommand.new )
419: self.add_command( ShowCommand.new( self ) )
420: self.add_command( UseCommand.new( self ) )
421: self.add_command( CmdParse::HelpCommand.new )
422: self.add_command( CmdParse::VersionCommand.new )
423: self.add_command( CheckCommand.new( self ) )
424: end
# File lib/webgen/cli.rb, line 426
426: def param_for_plugin( plugin_name, param )
427: if [plugin_name, param] == ['Core/Configuration', 'loggerLevel'] && @verbosity != VERBOSITY_UNUSED
428: @verbosity
429: elsif @config_file
430: @config_file.param_for_plugin( plugin_name, param )
431: else
432: Webgen::PluginParamValueNotFound
433: end
434: end
# File lib/webgen/cli.rb, line 436
436: def parse( argv = ARGV )
437: super do |level, cmd_name|
438: if level == 0
439: @config_file = Webgen::WebSite.load_config_file( @directory )
440: @website = Webgen::WebSite.new( @directory, self )
441: @website.manager.init
442: @website.manager.plugins.
443: each {|name,plugin| self.add_command( plugin ) if plugin.kind_of?( Webgen::CommandPlugin ) }
444: end
445: end
446: end