Class: GitOpenRemote::CLI

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/git_open_remote/cli.rb

Instance Method Summary collapse

Instance Method Details

#runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/git_open_remote/cli.rb', line 5

def run
  program :name, 'git-open-remote'
  program :version, GitOpenRemote::VERSION
  program :description, 'Open your git remote in browser'

  command :open do |cmd|
    cmd.syntax = 'open origin'
    cmd.description = 'Open remote url in browser'
    cmd.action do |args, _|
      git = Git.open(Dir.pwd)
      url = git.remote(args[0]).url
      return say "Looks like #{name} doesn't exist ;(" unless url

      Launchy.open(parse_url(url))
    end
  end

  default_command :open
  run!
end