lib/yard/cli/command.rb in yard-0.6.1 vs lib/yard/cli/command.rb in yard-0.6.2
- old
+ new
@@ -22,17 +22,16 @@
# @return [void]
def common_options(opts)
opts.separator ""
opts.separator "Other options:"
opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
- begin
- require(file.gsub(/\.rb$/, ''))
- rescue LoadError
- log.error "The file `#{file}' could not be loaded, check the path and try again."
- exit
- end
+ load_script(file)
end
+ opts.on('--plugin PLUGIN', 'Load a YARD plugin (gem with `yard-\' prefix)') do |name|
+ # Not actually necessary to load here, this is done at boot in YARD::Config.load_plugins
+ # YARD::Config.load_plugin(name)
+ end
opts.on('--legacy', 'Use old style Ruby parser and handlers. Always on in 1.8.x.') do
YARD::Parser::SourceParser.parser_type = :ruby18
end
opts.on_tail('-q', '--quiet', 'Show no warnings.') { log.level = Logger::ERROR }
opts.on_tail('--verbose', 'Show more information.') { log.level = Logger::INFO }
@@ -50,9 +49,22 @@
# @return [void]
def parse_options(opts, args)
opts.parse!(args)
rescue OptionParser::InvalidOption => e
log.warn "Unrecognized/#{e.message}"
+ end
+
+ # Loads a Ruby script. If +Config.options[:safe_mode]+ is enabled,
+ # this method will do nothing.
+ #
+ # @param [String] file the path to the script to load
+ # @since 0.6.2
+ def load_script(file)
+ return if YARD::Config.options[:safe_mode]
+ require(file.gsub(/\.rb$/, ''))
+ rescue LoadError
+ log.error "The file `#{file}' could not be loaded, check the path and try again."
+ exit
end
end
end
end
\ No newline at end of file