Sha256: f984fde9ff246071bdd74ddf8740d4de2d8f788127f9cd8061d77854cbf84a28

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module ZencoderCLI::Command
  class Plugins < Base

    provides "plugins", { "plugins:list" => "Lists installed plugins",
                          "plugins:install" => "Install a plugin via URL",
                          "plugins:uninstall" => "Uninstall a plugin" }

    class << self

      def list(args, global_options, command_options)
        if ZencoderCLI::Plugin.list.any?
          puts "The following plugins are installed:"
          ZencoderCLI::Plugin.list.each do |plugin|
            display "* #{plugin}"
          end
        else
          display "There are no plugins installed."
        end
      end

      def install(args, global_options, command_options)
        plugin = ZencoderCLI::Plugin.new(args.shift)
        if plugin.install
          begin
            ZencoderCLI::Plugin.load_plugin(plugin.name)
          rescue Exception => e
            installation_failed(plugin, e.message)
          end
          display "#{plugin} installed."
        else
          error "Could not install #{plugin}. Please check the URL and try again."
        end
      end

      def uninstall(args, global_options, command_options)
        plugin = ZencoderCLI::Plugin.new(args.shift)
        plugin.uninstall
        display "#{plugin} uninstalled."
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zencoder-2.2.2 lib/zencoder/cli/commands/plugins.rb
zencoder-2.2.1 lib/zencoder/cli/commands/plugins.rb
zencoder-2.2.0 lib/zencoder/cli/commands/plugins.rb