Class: Vimmer::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/vimmer/cli.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



47
48
49
50
# File 'lib/vimmer/cli.rb', line 47

def method_missing(name, *args)
  $stderr.puts 'Could not find command "%s".' % name
  exit 1
end

Instance Method Details

#install(path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vimmer/cli.rb', line 8

def install(path)
  setup
  begin
    installer = Vimmer::Installers.for_url(path)
    # TODO: Make this consistent with VimDotOrg installer
    if installer == Vimmer::Installers::Github
      installer = installer.new(:path => path)
    end
    installer.install
  rescue Vimmer::InstallerNotFoundError => e
    $stderr.puts "The URL #{e.path} is invalid."
    exit 1
  rescue Vimmer::InvalidPathError => e
    $stderr.puts "The URL #{e.path} is invalid."
    exit 1
  rescue Vimmer::PluginNotFoundError
    $stderr.puts "The plugin #{installer.plugin_name} could not be found"
    exit 1
  end
end

#uninstall(name) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/vimmer/cli.rb', line 31

def uninstall(name)
  unless Vimmer.plugin?(name)
    $stderr.puts "The plugin #{name} is not installed."
    exit 1
  end
  installer = Vimmer::Installers::Github.new(:name => name)
  installer.uninstall
end