Class: VimGet::Commands::UninstallCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/vimget/commands/uninstall_command.rb

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

#invoke, #show_help

Constructor Details

#initializeUninstallCommand

Returns a new instance of UninstallCommand.



23
24
25
26
27
28
29
30
31
# File 'lib/vimget/commands/uninstall_command.rb', line 23

def initialize
  super("uninstall", "Uninstall a script")
  
  add_option('--purge', 
      'Remove all associated files, including vim-get manifest') { |v,opts| opts[:purge] = v }
      
  add_option('--dry-run', 
      'Do not motify any files') { |v,opts| opts[:dry_run] = v }
end

Instance Method Details

#argumentsObject



37
38
39
# File 'lib/vimget/commands/uninstall_command.rb', line 37

def arguments
  "SCRIPT\t\tname of script to uninstall"
end

#executeObject

Raises:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vimget/commands/uninstall_command.rb', line 41

def execute
  args = fetch_arguments
  raise CommandLineError, "You must indicate one script at least to uninstall." if args.empty?
  
  installer = Installer.new(@options)
  args.each do |name|
    script = VimGet.db.find(name)
    raise UnknownScriptError, "This script is not installed yet." if script.nil?
    
    installer.uninstall(script)
  end
end

#usageObject



33
34
35
# File 'lib/vimget/commands/uninstall_command.rb', line 33

def usage
  "#{@program_name} SCRIPT [SCRIPT ...] "
end