Module: RShare::Options

Defined in:
lib/rshare/opts.rb

Class Method Summary collapse

Class Method Details

.parse!(args) ⇒ 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
29
30
# File 'lib/rshare/opts.rb', line 5

def self.parse!(args)
  opts = {}

  op = OptionParser.new { |op|
    op.banner = "Usage: #{$0} <push|pull> <configuration...> [option...]"
    op.separator ""
    op.separator "Options:"

    op.on("-d", "--daemonize", "Daemonize podshot") { |p|
      opts[:daemon] = true
    }

    op.on_tail("-h", "--help", "Show this message") {
      puts op
      Kernel.exit(1)
    }

    op.on_tail("-v", "--version", "Show version") {
      puts RShare::VERSION
      Kernel.exit(2)
    }
  }

  op.parse!(args)
  opts
end