Sha256: ee8cd8a162db4d059ce47bd4e1d032ba475394b5efda741751cfad74f94f19db

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'thor'
require 'vimmer'

module Vimmer
  class CLI < Thor

    desc "install PATH", "Installs plugin available at path PATH"
    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


    desc "uninstall NAME", "Removes plugin named NAME"
    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

    private

    def setup
      Vimmer.setup
    end


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


  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vimmer-0.2.0 lib/vimmer/cli.rb