Class: Gpr::Commands::List

Inherits:
Base
  • Object
show all
Defined in:
lib/gpr/commands/list.rb

Constant Summary

Constants included from Gpr

APP_PATH, VERSION

Instance Method Summary collapse

Methods inherited from Base

inherited

Constructor Details

#initialize(thor) ⇒ List

Returns a new instance of List.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gpr/commands/list.rb', line 8

def initialize(thor)
  thor.class_eval do
    desc 'list', 'Show all registered repositories'
    option :paths, type: :boolean, desc: 'Show the paths of all registered repositories'
    def list
      repositories = repository_list
      if options[:paths]
        repositories.each do |repository|
          puts repository
        end
      else
        repositories.each do |repository|
          repo_info = parse_repository(repository)

          puts "#{repo_info[:host].color(:yellow)} - #{repo_info[:repository].color(:blue)}"
        end
      end
    end
  end
end