Class: HubMerge::Options
- Inherits:
-
Object
- Object
- HubMerge::Options
- Defined in:
- lib/hubmerge/options.rb
Class Method Summary collapse
Class Method Details
.all ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hubmerge/options.rb', line 5 def self.all { repo: { short_switch: "-r", long_switch: "--repo ORG/REPONAME", type: String, description: "Github repository to search for PRs in (example: rails/rails)", }, query: { short_switch: "-q", long_switch: "--query ORG/REPONAME", type: String, description: "GitHub search query to run to find PRs (example: 'author:app/dependabot')", }, merge_without_confirmation: { short_switch: "-y", long_switch: "--yes", type: :flag, description: "Merge without confirmation from user (default: false)", }, } end |
.parse(argv) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hubmerge/options.rb', line 30 def self.parse(argv) parsed = {} opt_parser = OptionParser.new all.each do |key, params| if params[:type] == :flag opt_parser.on( params[:short_switch], params[:long_switch], params[:description] ) { |v| parsed[key] = v } else opt_parser.on( params[:short_switch], params[:long_switch], params[:type], params[:description] ) { |v| parsed[key] = v } end end opt_parser.parse(argv) parsed end |