From 5e0040ddd327a55f875aec8bd84c72a547caeeba Mon Sep 17 00:00:00 2001 From: lihan Date: Sun, 21 Apr 2024 17:59:46 +0800 Subject: [PATCH] chore: improve `update --all` output format --- cmd/commands/update.go | 8 +++++++- internal/manager.go | 8 -------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/commands/update.go b/cmd/commands/update.go index 374dd129..6072c9db 100644 --- a/cmd/commands/update.go +++ b/cmd/commands/update.go @@ -45,9 +45,15 @@ func updateCmd(ctx *cli.Context) error { defer manager.Close() if ctx.Bool(allFlag) { if sdks, err := manager.LoadAllSdk(); err == nil { + var ( + index int + total = len(sdks) + ) for sdk := range sdks { + index++ + pterm.Printf("[%s/%d]: Updating %s plugin...\n", pterm.Green(index), total, pterm.Green(sdk)) if err = manager.Update(sdk); err != nil { - pterm.Println(fmt.Sprintf("update plugin(%s) failed, %s", sdk, err.Error())) + pterm.Println(fmt.Sprintf("Update plugin(%s) failed, %s", sdk, err.Error())) } } } else { diff --git a/internal/manager.go b/internal/manager.go index 2c78556c..18be74d1 100644 --- a/internal/manager.go +++ b/internal/manager.go @@ -384,14 +384,6 @@ func (m *Manager) downloadPlugin(downloadUrl string) (string, error) { return path, nil } -func (m *Manager) pluginExist(name, alias string) bool { - pname := name - if len(alias) > 0 { - pname = alias - } - return util.FileExists(filepath.Join(m.PathMeta.PluginPath, pname)) -} - // Add a plugin to plugin home directory // 1. If the plugin is an official plugin, fetch the plugin manifest from the registry. // 2. If the plugin is a custom plugin, install the plugin from the specified URL.