Sha256: b32ae1e95972d4eb0e3a20f2f6f05bf3291ed047f17c53760c2779d31d1f4b75

Contents?: true

Size: 738 Bytes

Versions: 4

Compression:

Stored size: 738 Bytes

Contents

require 'optparse'

module Grog
  class Options
    attr_accessor :number_of_commits_to_show, :show_datetimes

    def self.parse(argv)
      Options.new(argv)
    end

    def initialize(argv)
      @opts = OptionParser.new

      @number_of_commits_to_show = 10
      @opts.on("-n=N", "number of commits to show", Integer) { |val| @number_of_commits_to_show = val }

      @show_datetimes = false
      @opts.on("-d", "show datetimes") { @show_datetimes = true }
      @opts.on_tail("-h", "--help", "Show this message") do
        puts @opts
        exit
      end
      @opts.on_tail("--version", "Show the version of the grog gem") do
        puts "grog v" + `cat VERSION`
      end

      @rest = @opts.parse(argv)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grog-0.0.6 lib/grog/options.rb
grog-0.0.5 lib/grog/options.rb
grog-0.0.4 lib/grog/options.rb
grog-0.0.3 lib/grog/options.rb