From a60f3c3ca0491dc8ef20c47877309d23f4a21633 Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Sun, 17 Sep 2023 16:04:21 +0200 Subject: [PATCH] Move prints out of downloadFile function Use command to print --- cmd/plugin_install.go | 14 +++++++++----- cmd/utils.go | 4 ---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/plugin_install.go b/cmd/plugin_install.go index 548289e3..3cc56eb5 100644 --- a/cmd/plugin_install.go +++ b/cmd/plugin_install.go @@ -85,7 +85,7 @@ var pluginInstallCmd = &cobra.Command{ splittedURL := strings.Split(args[0], "@") // If the version is not specified, use the latest version. if len(splittedURL) < NumParts { - log.Println("Version not specified. Using latest version") + cmd.Println("Version not specified. Using latest version") } if len(splittedURL) >= NumParts { pluginVersion = splittedURL[1] @@ -138,7 +138,9 @@ var pluginInstallCmd = &cobra.Command{ strings.Contains(name, archiveExt) }) if downloadURL != "" && releaseID != 0 { + cmd.Println("Downloading", downloadURL) downloadFile(client, account, pluginName, downloadURL, releaseID, pluginFilename) + cmd.Println("Download completed successfully") } else { log.Panic("The plugin file could not be found in the release assets") } @@ -148,7 +150,9 @@ var pluginInstallCmd = &cobra.Command{ return strings.Contains(name, "checksums.txt") }) if checksumsFilename != "" && downloadURL != "" && releaseID != 0 { + cmd.Println("Downloading", downloadURL) downloadFile(client, account, pluginName, downloadURL, releaseID, checksumsFilename) + cmd.Println("Download completed successfully") } else { log.Panic("The checksum file could not be found in the release assets") } @@ -174,13 +178,13 @@ var pluginInstallCmd = &cobra.Command{ log.Panic("Checksum verification failed") } - log.Println("Checksum verification passed") + cmd.Println("Checksum verification passed") break } } if pullOnly { - log.Println("Plugin binary downloaded to", pluginFilename) + cmd.Println("Plugin binary downloaded to", pluginFilename) return } } else { @@ -204,7 +208,7 @@ var pluginInstallCmd = &cobra.Command{ pluginFileSum := "" for _, filename := range filenames { if strings.Contains(filename, pluginName) { - log.Println("Plugin binary extracted to", filename) + cmd.Println("Plugin binary extracted to", filename) localPath = filename // Get the checksum for the extracted plugin binary. // TODO: Should we verify the checksum using the checksum.txt file instead? @@ -303,7 +307,7 @@ var pluginInstallCmd = &cobra.Command{ } // TODO: Add a rollback mechanism. - log.Println("Plugin installed successfully") + cmd.Println("Plugin installed successfully") }, } diff --git a/cmd/utils.go b/cmd/utils.go index 52129295..ea4d4598 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -393,8 +393,6 @@ func downloadFile( client *github.Client, account, pluginName, downloadURL string, releaseID int64, filename string, ) { - log.Println("Downloading", downloadURL) - // Download the plugin. readCloser, redirectURL, err := client.Repositories.DownloadReleaseAsset( context.Background(), account, pluginName, releaseID, http.DefaultClient) @@ -447,6 +445,4 @@ func downloadFile( if err != nil { log.Panic("There was an error downloading the plugin: ", err) } - - log.Println("Download completed successfully") }