Class: Ghstars::CLI
- Inherits:
-
Thor
- Object
- Thor
- Ghstars::CLI
- Defined in:
- lib/ghstars/cli.rb
Instance Method Summary collapse
Instance Method Details
#list(top_repos = 0) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/ghstars/cli.rb', line 44 def list(top_repos=0) top_repos = top_repos.to_i if is_numeric?(top_repos) puts "Fetching repositories, please hold..." if [:verbose] query = {visibility: 'public', affiliation: 'owner'} repos = Ghstars.get_repos(query: query) repos = repos[0..(top_repos-1)] if top_repos > 0 puts tabelize(repos, top_repos) end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ghstars/cli.rb', line 22 def show puts "Fetching repositories, please hold..." if [:verbose] query = {visibility: 'public', affiliation: 'owner'} repos = Ghstars.get_repos(query: query) star_count = repos.map{|r| r[:stargazers_count]}.sum if [:verbose] puts "You have #{star_count} #{star_count > 1 ? "stars" : "star"}" else puts star_count end end |