Class: Reponaut::Application::List
Instance Attribute Summary
Attributes inherited from Command
#client, #repos, #username
Instance Method Summary
collapse
Methods inherited from Command
inherited, #quit, subclasses
Constructor Details
#initialize(prog) ⇒ 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, options|
process(options, 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(options, args)
super
language = args[1]
quit 6, 'Only one of -l and -d may be specified' if options['show_description'] && options['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(options).new
filtered_repos.sort.each do |r|
puts formatter.format(r)
end
end
|