Fixes messages for plugin remove option

Fixes issues/2398 - helm plugin remove does not works as expected

- [ ] plugin remove option is coded to remove multiple plugins, but instead returns error when more than one plugin is requested to be removed.
- [ ] plugin remove does not show any error/message for non-existent plugin.
pull/2400/head
Sushil Kumar 8 years ago
parent c84fb11a68
commit 1c5aab8e78

@ -16,6 +16,7 @@ limitations under the License.
package main package main
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -48,8 +49,8 @@ func newPluginRemoveCmd(out io.Writer) *cobra.Command {
} }
func (pcmd *pluginRemoveCmd) complete(args []string) error { func (pcmd *pluginRemoveCmd) complete(args []string) error {
if err := checkArgsLength(len(args), "plugin"); err != nil { if len(args) == 0 {
return err return errors.New("please provide plugin name to remove")
} }
pcmd.names = args pcmd.names = args
pcmd.home = settings.Home pcmd.home = settings.Home
@ -67,10 +68,13 @@ func (pcmd *pluginRemoveCmd) run() error {
for _, name := range pcmd.names { for _, name := range pcmd.names {
if found := findPlugin(plugins, name); found != nil { if found := findPlugin(plugins, name); found != nil {
if err := removePlugin(found, pcmd.home); err != nil { if err := removePlugin(found, pcmd.home); err != nil {
return err fmt.Fprintf(pcmd.out, "Failed to remove plugin %s, got error (%v)\n", name, err)
} } else {
fmt.Fprintf(pcmd.out, "Removed plugin: %s\n", name) fmt.Fprintf(pcmd.out, "Removed plugin: %s\n", name)
} }
} else {
fmt.Fprintf(pcmd.out, "Plugin: %s not found\n", name)
}
} }
return nil return nil
} }

Loading…
Cancel
Save