Class: Giturl::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/giturl/options.rb

Overview

The options giturl accepts on the command line, and the values a given command line puts in them.

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



10
11
12
# File 'lib/giturl/options.rb', line 10

def initialize
  @values = {}
end

Instance Method Details

#parse!(argv) ⇒ Hash

Consumes the options from argv, leaving the target directories behind. --app names a browser, which only makes sense together with --open, so it turns --open on by itself.

Parameters:

  • argv (Array<String>)

    the command line, modified in place

Returns:

  • (Hash)

    the values given, keyed by long option name



20
21
22
23
24
25
26
# File 'lib/giturl/options.rb', line 20

def parse!(argv)
  OptionParser.new do |opts|
    definitions(opts).parse!(argv, into: @values)
    @values[:open] = true if @values.key?(:app)
  end
  @values
end