Class: Pod::Command::GiteeRepo::List
- Inherits:
-
Pod::Command::GiteeRepo
- Object
- Pod::Command
- Pod::Command::GiteeRepo
- Pod::Command::GiteeRepo::List
- Defined in:
- lib/pod/command/gitee_repo/list.rb
Constant Summary collapse
- UTIL =
Pod::GiteeRepo::GiteeRepoUtil
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ List
constructor
A new instance of List.
- #print_gitee_repos(repos) ⇒ Object
- #print_gitee_repos_count(repos) ⇒ Object
- #run ⇒ Object
Methods inherited from Pod::Command::GiteeRepo
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
.options ⇒ Object
17 18 19 20 21 |
# File 'lib/pod/command/gitee_repo/list.rb', line 17 def self. [ ['--count-only', 'Show the total number of repos'] ].concat(super) end |
Instance Method Details
#print_gitee_repos(repos) ⇒ Object
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 |
#print_gitee_repos_count(repos) ⇒ Object
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 |
#run ⇒ Object
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 |