class StillActive::Options
Attributes
options[RW]
options_parser[RW]
Public Class Methods
new()
click to toggle source
# File lib/still_active/options.rb, line 9 def initialize @options = {} @options_parser = OptionParser.new do |opts| add_banner(opts) add_tail_options(opts) add_gemfile_option(opts) add_gems_option(opts) add_output_options(opts) add_token_options(opts) add_parallelism_options(opts) add_range_options(opts) add_emoji_options(opts) end end
Public Instance Methods
parse!(args)
click to toggle source
# File lib/still_active/options.rb, line 24 def parse!(args) options_parser.parse!(args) validate_options options end
Private Instance Methods
add_emoji_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 78 def add_emoji_options(opts) opts.on("--critical-warning-emoji=EMOJI") { |value| StillActive.config { |config| config.critical_warning_emoji = value } } opts.on("--futurist-emoji=EMOJI") { |value| StillActive.config { |config| config.futurist_emoji = value } } opts.on("--success-emoji=EMOJI") { |value| StillActive.config { |config| config.success_emoji = value } } opts.on("--unsure-emoji=EMOJI") { |value| StillActive.config { |config| config.unsure_emoji = value } } opts.on("--warning-emoji=EMOJI") { |value| StillActive.config { |config| config.warning_emoji = value } } end
add_gemfile_option(opts)
click to toggle source
# File lib/still_active/options.rb, line 36 def add_gemfile_option(opts) opts.on("--gemfile=GEMFILE", String, "path to gemfile") do |value| options[:provided_gemfile] = true StillActive.config { |config| config.gemfile_path = value } end end
add_gems_option(opts)
click to toggle source
# File lib/still_active/options.rb, line 43 def add_gems_option(opts) opts.on("--gems=GEM,GEM2,...", Array, "Gem(s)") do |value| options[:provided_gems] = true StillActive.config { |config| config.gems = value } end end
add_output_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 50 def add_output_options(opts) opts.on("--markdown", "Prints output in markdown format") { StillActive.config { |config| config.output_format = :markdown } } opts.on("--json", "Prints output in JSON format") { StillActive.config { |config| config.output_format = :json } } end
add_parallelism_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 61 def add_parallelism_options(opts) opts.on("--simultaneous-requests=QTY", Integer, "Number of simultaneous requests made") do |value| StillActive.config { |config| config.parallelism = value } end end
add_range_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 67 def add_range_options(opts) opts.on("--no-warning-range-end=YEARS", Integer, "maximum number of years since last activity until which you do not want to be warned about ") do |value| StillActive.config { |config| config.no_warning_range_end = value } end opts.on("--warning-range-end=YEARS", Integer, "maximum number of years since last activity that you want to be warned about") do |value| StillActive.config { |config| config.warning_range_end = value } end end
add_tail_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 95 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 StillActive::VERSION exit end end
add_token_options(opts)
click to toggle source
# File lib/still_active/options.rb, line 55 def add_token_options(opts) opts.on("--github-oauth-token=TOKEN", String, "GitHub OAuth token to make API calls") do |value| StillActive.config { |config| config.github_oauth_token = value } end end
validate_options()
click to toggle source
# File lib/still_active/options.rb, line 32 def validate_options raise ArgumentError, "provide gemfile or gems, not both" if options[:provided_gemfile] && options[:provided_gems] end