Class: GitGoggles::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/git_goggles/cli.rb

Instance Method Summary collapse

Instance 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
# File 'lib/git_goggles/cli.rb', line 4

def parse!(args)
  args, options = args.dup, {}

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: git-goggles [options]"
    opts.on("-R", "--root-dir=path", String,
            "GitGoggles root directory") { |v| options[:root_dir] = v }

    opts.separator ""

    opts.on("-p", "--port=port", Integer,
            "Runs GitGoggles on the specified port.", "Default: 9292") { |v| options[:Port] = v }
    opts.on("-b", "--binding=ip", String,
            "Binds GitGoggles to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v }
    opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true }
    opts.on("-P","--pid=pid",String,
            "Specifies the PID file.",
            "Default: rack.pid") { |v| options[:pid] = v }

    opts.separator ""

    opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
  end

  opt_parser.parse! args

  options[:config] = File.expand_path("../../config.ru", File.dirname(__FILE__))
  options
end