示例#1
0
func pluginDelete(c *cli.Context) {
	// Input validation
	printableName := c.Args()[0]
	if printableName == "" {
		log.Fatalf("Missing plugin name")
	}

	pluginName, pluginType, err := plugins.ParsePrintableName(printableName)
	if err != nil {
		log.Fatalf("Failed to parse plugin name, err: %s", err)
	}

	// Delete
	log.Infof("=> Deleting plugin (%s) ...", printableName)
	if err := plugins.DeletePlugin(pluginName, pluginType); err != nil {
		log.Fatalf("Failed to delete plugin, err: %s", err)
	}
	log.Infof("Done")
}
示例#2
0
func pluginDelete(c *cli.Context) error {
	// Input validation
	if len(c.Args()) == 0 {
		log.Fatal("Missing plugin name")
	}

	name := c.Args()[0]
	if name == "" {
		log.Fatal("Missing plugin name")
	}

	if _, found, err := plugins.LoadPlugin(name); err != nil {
		log.Fatalf("Failed to check if plugin (%s) installed, error: %s", name, err)
	} else if !found {
		log.Fatalf("Plugin (%s) is not installed", name)
	}

	versionPtr, err := plugins.GetPluginVersion(name)
	if err != nil {
		log.Fatalf("Failed to read plugin (%s) version, error: %s", name, err)
	}

	// Delete
	version := "local"
	if versionPtr != nil {
		version = versionPtr.String()
	}
	log.Infof("=> Deleting plugin (%s) with version (%s) ...", name, version)
	if err := plugins.DeletePlugin(name); err != nil {
		log.Fatalf("Failed to delete plugin (%s) with version (%s), error: %s", name, version, err)
	}

	fmt.Println()
	log.Infof(colorstring.Greenf("Plugin (%s) with version (%s) deleted", name, version))

	return nil
}