class AnnotateGem::Options
Attributes
options[RW]
options_parser[RW]
Public Class Methods
new()
click to toggle source
# File lib/annotate_gem/options.rb, line 8 def initialize @options = {} @options_parser = OptionParser.new do |opts| add_banner(opts) add_tail_options(opts) add_info_options(opts) add_gemfile_comment_options(opts) end end
Public Instance Methods
parse!(args)
click to toggle source
# File lib/annotate_gem/options.rb, line 18 def parse!(args) options_parser.parse!(args) validate_options options end
Private Instance Methods
add_gemfile_comment_options(opts)
click to toggle source
# File lib/annotate_gem/options.rb, line 40 def add_gemfile_comment_options(opts) opts.on("--new-comments-only", "Only add a comment to gemfile if there isn't a comment already (for non-inline comments)") do options[:new_comments_only] = true end opts.on("--inline", "Inline the comment") do options[:inline] = true end end
add_info_options(opts)
click to toggle source
# File lib/annotate_gem/options.rb, line 31 def add_info_options(opts) opts.on("--website-only", "Only output the website") do options[:website_only] = true end opts.on("--description-only", "Only output the description") do options[:description_only] = true end end
add_tail_options(opts)
click to toggle source
# File lib/annotate_gem/options.rb, line 58 def add_tail_options(opts) opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-v", "--version", "Show version") do puts AnnotateGem::VERSION exit end end
validate_options()
click to toggle source
# File lib/annotate_gem/options.rb, line 26 def validate_options info_flags = options[:website_only] && options[:description_only] raise ArgumentError, "Cannot set both --website-only and --description-only flags" if info_flags end