Class: Rcr::OptionParsing

Inherits:
Object
  • Object
show all
Defined in:
lib/rcr/option_parsing.rb

Class Method Summary collapse

Class Method Details

.parse(args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rcr/option_parsing.rb', line 6

def self.parse(args)
  options = {}

  OptionParser.new do |opts|
    opts.banner = "Usage: gem_sync [options]"

    opts.on('-p', '--platform [PLATFORM]', 'Specify an optional platform') do |o|
      options[:platform] = o.strip
    end

    opts.on('-g', '--github', 'Pull the list of gems to install from github') do |o|
      options[:github] = o
      options[:gem_list] = Rcr::GemSync::RCR_GITHUB_GEM_LIST
    end
    
    opts.on('-v', '--verbose', 'Run in verbose mode') do |o|
      options[:verbose] = o
    end
    
    opts.on('--verbose-gem', "Be verbose when calling gem commands") do |o|
      options[:verbose_gem] = o
    end
    
    opts.on('-n', '--dry-run', 'Do a dry run without executing actions') do |o|
      options[:dry_run] = o
    end
    
  end.parse!(args)

  options
end