Class: GitTools::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/git_tools/parse.rb

Class Method Summary collapse

Class Method Details

.parse!(args) ⇒ Object



4
5
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/git_tools/parse.rb', line 4

def self.parse!(args)
  options           = OpenStruct.new
  options.library   = args.first.sub(/(\s+)/, '_') unless args.first.nil?
  options.yaml      = Dir.pwd
  
  opts = OptionParser.new do |opts|
    
    opts.banner = "\nGit Tools Usage: gitools all will install all your git submodules"
    opts.separator "You must be in your Application Root Directory when running this command."
    opts.separator ""
    
    opts.on_tail('-v', '--version', "Show GitTools' current version.") do
      puts "\nGit Tools is at version #{GitTools::Version}\n"
      exit(0)
    end
    
    opts.on_tail('-h', '--help', "Help Me!") do
      puts "#{opts}\n"
      exit(0)
    end
    
    opts.on_tail do
      if options.library.nil? || options.library == ''
        puts "\nYou need to tell me what you want library you want to add to git submodule."
        puts "#{opts}\n"
        exit(0)
      end
    end  
  end # OptionParser
  
  opts.parse!(args)
  options
end