Class: VimGet::Commands::ListCommand

Inherits:
BaseCommand show all
Defined in:
lib/vimget/commands/list_command.rb

Direct Known Subclasses

InstalledCommand, OutdatedCommand

Constant Summary

Constants inherited from BaseCommand

BaseCommand::PROGRAM

Instance Attribute Summary

Attributes inherited from BaseCommand

#command, #defaults, #options, #options_group, #program_name, #summary

Instance Method Summary collapse

Methods inherited from BaseCommand

#arguments, #invoke, #show_help, #usage

Constructor Details

#initialize(name = 'list', summary = 'Display all script in local') ⇒ ListCommand

Returns a new instance of ListCommand.



15
16
17
18
19
20
21
# File 'lib/vimget/commands/list_command.rb', line 15

def initialize(name = 'list', summary = 'Display all script in local')
  super(name,
    summary,
    :format => "plain")
  
  add_customer_options
end

Instance Method Details

#executeObject

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vimget/commands/list_command.rb', line 23

def execute
  raise CommandLineError, "Ambiguous command!" if @options[:outdated] && @options[:installed]
    
  if @options[:outdated]
    scripts = VimGet.db.outdated_scripts
  elsif @options[:installed]
    scripts = VimGet.db.installed_scripts
  else
    scripts = VimGet.db.search
  end
 
  outputer = Output.new(@options[:format])
  outputer.short(scripts)
end