Class: Reponaut::Application::List
- Defined in:
- lib/reponaut/commands/list.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
-
#initialize(prog) ⇒ List
constructor
A new instance of List.
- #process(options, args) ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(prog) ⇒ List
Returns a new instance of List.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/reponaut/commands/list.rb', line 4 def initialize(prog) prog.command(:list) do |c| c.alias :ls c.syntax 'list [options] <username> [language]' c.description "List a user's repos" c.option 'ignore_forks', '-f', 'Ignore forks' c.option 'show_description', '-d', 'Show repo description' c.option 'show_language', '-l', 'Show repo language' c.action do |args, | process(, args) end end end |
Instance Method Details
#process(options, args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/reponaut/commands/list.rb', line 19 def process(, args) super language = args[1] quit 6, 'Only one of -l and -d may be specified' if ['show_description'] && ['show_language'] filtered_repos = repos filtered_repos = filtered_repos.select { |r| r.language.downcase == language.downcase } if language if filtered_repos.empty? msg = "#{username} has no repositories" msg += " written in #{language}" if language quit 4, msg end formatter = formatter_class().new filtered_repos.sort.each do |r| puts formatter.format(r) end end |