Sha256: a78dfaeb310f7f1e04700ef551955725316f6fe6313f427ff368c2fd32536b1c
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
require 'optparse' module YARD module CLI # Abstract base class for CLI utilities. Provides some helper methods for # the option parser # # @abstract class Base def initialize log.show_backtraces = false end protected # Adds a set of common options to the tail of the OptionParser # # @param [OptionParser] opts the option parser object # @return [void] def common_options(opts) opts.separator "" opts.separator "Other options:" opts.on_tail('-q', '--quiet', 'Show no warnings.') { log.level = Logger::ERROR } opts.on_tail('--verbose', 'Show more information.') { log.level = Logger::INFO } opts.on_tail('--debug', 'Show debugging information.') { log.level = Logger::DEBUG } opts.on_tail('--backtrace', 'Show stack traces') { log.show_backtraces = true } opts.on_tail('-v', '--version', 'Show version.') { puts "yard #{YARD::VERSION}"; exit } opts.on_tail('-h', '--help', 'Show this help.') { puts opts; exit } end # Parses the option and gracefully handles invalid switches # # @param [OptionParser] opts the option parser object # @param [Array<String>] args the arguments passed from input. This # array will be modified. # @return [void] def parse_options(opts, args) opts.parse!(args) rescue OptionParser::InvalidOption => e log.warn "Unrecognized/#{e.message}" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
yard-0.5.8 | lib/yard/cli/base.rb |
yard-0.5.7 | lib/yard/cli/base.rb |
yard-0.5.6 | lib/yard/cli/base.rb |
yard-0.5.5 | lib/yard/cli/base.rb |
yard-0.5.4 | lib/yard/cli/base.rb |