From 3445388db3ad88cbab19a11174b8fea85e49b8e7 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 12 Feb 2015 12:50:40 -0400 Subject: [PATCH] Implement plugin rm command --- lib/actions/plugin.coffee | 39 +++++++++++++++++++++++++++++++++++++++ lib/app.coffee | 1 + 2 files changed, 40 insertions(+) diff --git a/lib/actions/plugin.coffee b/lib/actions/plugin.coffee index e23f587b..bb985f10 100644 --- a/lib/actions/plugin.coffee +++ b/lib/actions/plugin.coffee @@ -3,6 +3,7 @@ _.str = require('underscore.string') async = require('async') npm = require('npm') visuals = require('resin-cli-visuals') +commandOptions = require('./command-options') exports.list = signature: 'plugins' @@ -72,6 +73,8 @@ exports.install = "resin-plugin-#{params.name}" ], callback) + # TODO: Print installed plugins names + ], (error) -> return done() if not error? @@ -79,3 +82,39 @@ exports.install = error.message = "Plugin not found: #{params.name}" return done(error) if error? + +exports.remove = + signature: 'plugin rm ' + description: 'remove a plugin' + help: ''' + Use this command to remove a resin.io plugin. + + Notice this command asks for confirmation interactively. + You can avoid this by passing the `--yes` boolean option. + + Examples: + $ resin plugin rm hello + $ resin plugin rm hello --yes + ''' + options: [ commandOptions.yes ] + permission: 'user' + action: (params, options, done) -> + async.waterfall([ + + (callback) -> + npm.load(loglevel: 'silent', callback) + + (data, callback) -> + visuals.patterns.remove 'plugin', options.yes, (callback) -> + npm.commands.uninstall([ + "resin-plugin-#{params.name}" + ], callback) + , callback + + (uninstalledPlugins, callback) -> + if _.isEmpty(uninstalledPlugins) + return callback(new Error("Plugin not found: #{params.name}")) + console.info("Plugin removed: #{params.name}") + return callback() + + ], done) diff --git a/lib/app.coffee b/lib/app.coffee index 10a9867a..799fb6b9 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -103,6 +103,7 @@ capitano.command(actions.examples.info) # ---------- Plugins Module ---------- capitano.command(actions.plugin.list) capitano.command(actions.plugin.install) +capitano.command(actions.plugin.remove) changeProjectDirectory = (directory) -> try