Class: DevTools::PRlist::OptParse
- Inherits:
-
Object
- Object
- DevTools::PRlist::OptParse
- Defined in:
- lib/pr_list/options.rb
Class Method Summary collapse
- .default_options ⇒ Object
- .label_values ⇒ Object
- .parse(argv_opts = [], unit_testing = false) ⇒ Object
- .validate_options ⇒ Object
Class Method Details
.default_options ⇒ Object
6 7 8 9 10 11 |
# File 'lib/pr_list/options.rb', line 6 def self. { markdown: false, queue: false } end |
.label_values ⇒ Object
50 51 52 |
# File 'lib/pr_list/options.rb', line 50 def self.label_values Options.labels.keys.map { |k| Options.labels[k] }.flatten.compact end |
.parse(argv_opts = [], unit_testing = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pr_list/options.rb', line 19 def self.parse(argv_opts = [], unit_testing = false) opt_parse = DevTools::OptParse.new({ name: IDENT, version: VERSION, defaults: , testing: unit_testing }) parser = opt_parse.parser parser. = "Usage: #{DevTools::PROGRAM} [OPTIONS]" parser.separator "" parser.separator "[OPTIONS]" parser.on "-m", "--markdown", "Outputs in markdown friendly format" do Options.markdown = true end parser.on "--[no-]queue", "filters PRs into a queue list for QA" do |opt| Options.queue = opt end parser.separator "" parser.separator "Common Options:" parser.parse!(argv_opts) unless unit_testing Options end |
.validate_options ⇒ Object
13 14 15 16 17 |
# File 'lib/pr_list/options.rb', line 13 def self. raise RuntimeError, "Missing configuration file" if Options.nil? raise RuntimeError, "Missing authentication token" if Options.token.nil? raise RuntimeError, "No repositories provided" if Options.repos.empty? end |