Class: Vim::Jar::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/vim-jar/cli.rb

Instance Method Summary collapse

Instance Method Details

#import(github_url) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/vim-jar/cli.rb', line 36

def import(github_url)
  begin 
    ::Vim::Jar::Importer.import(github_url)
    STDOUT.puts "'#{github_url}' has import to our local cache"
  rescue ImportError => e 
    STDERR.puts "Can not import '#{github_url}', because #{e.message}"
  end
end

#initObject



9
10
11
12
# File 'lib/vim-jar/cli.rb', line 9

def init 
  check!
  done
end

#install(plugin_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vim-jar/cli.rb', line 15

def install(plugin_name)
  check!
  plugin = ::Vim::Jar::Plugin.find(plugin_name)
  if plugin
    plugin.install 
  else
    STDERR.puts "Can not find plugin '#{plugin_name}'"
    STDERR.puts "you can run 'vim-jar list' to show all the existing plugins"
    exit 1
  end
end

#installedObject



46
47
48
# File 'lib/vim-jar/cli.rb', line 46

def installed
  STDOUT.puts ::Vim::Jar::Plugin.installed.join("\n")
end

#listObject



28
29
30
31
32
33
# File 'lib/vim-jar/cli.rb', line 28

def list
  str = ::Vim::Jar::Plugin.plugins.map do |plugin_attr| 
    "#{plugin_attr['name']}: #{plugin_attr['desc']}"
  end.join("\n")
  STDOUT.puts str
end

#uninstall(name) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/vim-jar/cli.rb', line 59

def uninstall(name)
  check!
  if ::Vim::Jar::Plugin.installed.include?(name)
    ::Vim::Jar::Plugin.uninstall(name)
    STDOUT.puts "plugin #{name} has been already remove from #{config.bundle_home.join(name)}"
  else
    STDERR.puts "You didn't install plugin named #{name}"
  end
  
end

#updateObject



51
52
53
54
55
56
# File 'lib/vim-jar/cli.rb', line 51

def update
  check!
  if ::Vim::Jar::Plugin.update 
    STDOUT.puts "All your plugin is up to date."
  end
end