Class: Git::Browse::Remote::Runner
- Inherits:
-
Object
- Object
- Git::Browse::Remote::Runner
- Defined in:
- lib/git/browse/remote/runner.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 |
# File 'lib/git/browse/remote/runner.rb', line 7 def initialize(args) @args = args @core = Core.new end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/git/browse/remote/runner.rb', line 12 def run OptionParser.new do |opt| opt. = 'git browse-remote [options] [<commit> | <remote>] [--] [<file>]' opt.version = VERSION opt.on('-r', '--remote=<remote>', 'specify remote') { |r| @core.remote = r } opt.on('--stdout', 'prints URL instead of opening browser') { @stdout = true } opt.on('--top', 'open `top` page') { @core.mode = :top } opt.on('--rev', 'open `rev` page') { @core.mode = :rev } opt.on('--ref', 'open `ref` page') { @core.mode = :ref } opt.on('--init [<host>=<recipe>]', 'initialize default url mappings') do |config| if config host, name = *config.split(/=/, 2) else host, name = 'github.com', 'github' end STDERR.puts "Writing config for #{host}..." @core.init!(host, name.to_sym) STDERR.puts 'Mappings generated:' exec "git config --get-regexp ^browse-remote\\.#{host}\\." end opt.on('-L <n>', 'specify line number (only meaningful on file mode)', Integer) { |n| @core.line = n } end.parse!(@args) @core.target, @core.file = *@args[0..1] if @stdout puts @core.url else exec 'git', 'web--browse', @core.url end end |