322: def initialize( cmdparser )
323: super( 'check', true )
324: self.short_desc = "Checks things like validity of the config file or the availability of optional libraries"
325:
326:
327: checkConfig = CmdParse::Command.new( 'config', false )
328: checkConfig.short_desc = "Checks the validity of the configuration and outputs the used options"
329: checkConfig.set_execution_block do |args|
330: begin
331: if File.exists?( File.join( cmdparser.directory, 'config.yaml' ) )
332: print CliUtils.section( "Checking configuration file syntax...", 50, 0, :bold )
333: config_file = ConfigurationFile.new( File.join( cmdparser.directory, 'config.yaml' ) )
334: puts Color.green( 'OK' )
335:
336: puts CliUtils.section( "Checking parameters...", 0, 0, :bold )
337: config_file.config.each do |plugin_name, params|
338: params.each do |param_name, value|
339: print CliUtils.section( "#{plugin_name}:#{param_name}", 50, 2, :reset )
340: if cmdparser.website.manager.plugin_class_for_name( plugin_name ).nil?
341: puts Color.lred( 'NOT OK' ) + ': no such plugin'
342: else
343: begin
344: cmdparser.website.manager.param_for_plugin( plugin_name, param_name )
345: puts Color.green( 'OK' )
346: rescue PluginParamNotFound => e
347: puts Color.lred( 'NOT OK' ) + ': no such parameter'
348: end
349: end
350: end
351: end
352: else
353: print CliUtils.section( "No configuration file found!", 50, 0, :bold )
354: end
355: rescue ConfigurationFileInvalid => e
356: puts Color.lred( 'NOT OK' ) + ': ' + e.message
357: end
358: end
359: self.add_command( checkConfig, true )
360:
361:
362: checkLibs = CmdParse::Command.new( 'libs', false )
363: checkLibs.short_desc = "Checks the availability of optional libraries used by plugins"
364: checkLibs.set_execution_block do |args|
365: puts CliUtils.format( "List of optional libraries (the info line specifies which functionality will be available " +
366: "if the needed gems are installed):" ).join("\n")
367: puts
368:
369: cmdparser.website.manager.plugin_loaders.each do |loader|
370: loader.optional_parts.sort.each do |name, options|
371: puts CliUtils.headline( name )
372: puts CliUtils.section( 'Info', 25 ) + CliUtils.format( options[:info], 25 ).join("\n")
373: puts CliUtils.section( 'Needed gems', 25 ) + options[:needed_gems].join( ', ' )
374: puts CliUtils.section( 'Loaded', 25 ) + ( options[:loaded] ? Color.green( 'yes' ) : Color.lred( 'no' ) )
375: puts CliUtils.section( 'Error message', 25 ) + CliUtils.format( options[:error_msg], 25 ).join("\n") unless options[:loaded]
376: puts
377: end
378: end
379: end
380: self.add_command( checkLibs )
381: end