Class: Giturl::CommandGiturl

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

Overview

command line wrapper

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



12
13
14
# File 'lib/command_giturl.rb', line 12

def params
  @params
end

Instance Method Details

#parse_optionsObject



14
15
16
17
18
19
20
21
# File 'lib/command_giturl.rb', line 14

def parse_options
  @params = {}
  OptionParser.new do |opts|
    opts = define_options(opts)
    opts.parse!(ARGV, into: @params)
    @params[:open] = true if @params.key?(:app)
  end
end

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/command_giturl.rb', line 23

def run
  ARGV << '.' if ARGV.empty?
  ARGV.each do |arg|
    if Giturl.git_managed?(arg)
      url = Giturl.convert(arg)
      print "#{url}\n"
      browser_open(url) if @params[:open]
    elsif @params[:verbose]
      print "Not git-managed-dir:  #{arg}\n"
    end
  end
end