Class: Pod::Command::GiteeRepo::List

Inherits:
Pod::Command::GiteeRepo show all
Defined in:
lib/pod/command/gitee_repo/list.rb

Constant Summary collapse

UTIL =
Pod::GiteeRepo::GiteeRepoUtil

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::GiteeRepo

#init

Constructor Details

#initialize(argv) ⇒ List

Returns a new instance of List.



23
24
25
26
27
# File 'lib/pod/command/gitee_repo/list.rb', line 23

def initialize(argv)
  init
  @count_only = argv.flag?('count-only')
  super
end

Class Method Details

.optionsObject



17
18
19
20
21
# File 'lib/pod/command/gitee_repo/list.rb', line 17

def self.options
  [
    ['--count-only', 'Show the total number of repos']
  ].concat(super)
end

Instance Method Details



37
38
39
40
41
42
43
44
45
# File 'lib/pod/command/gitee_repo/list.rb', line 37

def print_gitee_repos(repos)
  repos.each { |repo|
    UI.title repo.name do
      UI.puts "- Repo Url: #{repo.url}"
      UI.puts "- Local Repo Path: #{repo.path}"
    end
  }
  UI.puts "\n"
end


47
48
49
50
51
# File 'lib/pod/command/gitee_repo/list.rb', line 47

def print_gitee_repos_count(repos)
  number_of_repos = repos.length
  repo_string = number_of_repos != 1 ? 'repos' : 'repo'
  UI.puts "#{number_of_repos} #{repo_string}\n".green
end

#runObject



29
30
31
32
33
34
35
# File 'lib/pod/command/gitee_repo/list.rb', line 29

def run
  repos = UTIL.get_gitee_repos
  # 除 --count-only 外打印仓库信息
  print_gitee_repos(repos) unless @count_only
  # 打印仓库个数
  print_gitee_repos_count(repos)
end