From 0c4d5b2e6957eca7b0275bc4bc652d6707314e9b Mon Sep 17 00:00:00 2001 From: "Wiktor W." Date: Fri, 5 Jan 2024 19:16:54 +0100 Subject: [PATCH] chore: use Printf() instead of Println(Sprintf()) --- cli/app/list.go | 10 +++++----- cli/app/new.go | 6 +++--- cli/cli.go | 15 ++++++--------- cli/recipe/new.go | 4 ++-- cli/recipe/sync.go | 4 ++-- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/cli/app/list.go b/cli/app/list.go index 08dff6f2..c5e4ed30 100644 --- a/cli/app/list.go +++ b/cli/app/list.go @@ -270,17 +270,17 @@ can take some time. table.Render() if status { - fmt.Println(fmt.Sprintf( - "server: %s | total apps: %v | versioned: %v | unversioned: %v | latest: %v | upgrade: %v", + fmt.Printf( + "server: %s | total apps: %v | versioned: %v | unversioned: %v | latest: %v | upgrade: %v\n", app.Server, serverStat.AppCount, serverStat.VersionCount, serverStat.UnversionedCount, serverStat.LatestCount, serverStat.UpgradeCount, - )) + ) } else { - fmt.Println(fmt.Sprintf("server: %s | total apps: %v", app.Server, serverStat.AppCount)) + fmt.Printf("server: %s | total apps: %v\n", app.Server, serverStat.AppCount) } } @@ -292,7 +292,7 @@ can take some time. } if len(allStats) > 1 { - fmt.Println(fmt.Sprintf("total servers: %v | total apps: %v ", totalServersCount, totalAppsCount)) + fmt.Printf("total servers: %v | total apps: %v\n", totalServersCount, totalAppsCount) } return nil diff --git a/cli/app/new.go b/cli/app/new.go index 53870b55..c989b1f4 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -141,15 +141,15 @@ var appNewCommand = cli.Command{ table := formatter.CreateTable(tableCol) table.Append([]string{internal.NewAppServer, recipe.Name, internal.Domain}) - fmt.Println(fmt.Sprintf("A new %s app has been created! Here is an overview:", recipe.Name)) + fmt.Printf("A new %s app has been created! Here is an overview:\n", recipe.Name) fmt.Println("") table.Render() fmt.Println("") fmt.Println("You can configure this app by running the following:") - fmt.Println(fmt.Sprintf("\n abra app config %s", internal.Domain)) + fmt.Printf("\n abra app config %s\n", internal.Domain) fmt.Println("") fmt.Println("You can deploy this app by running the following:") - fmt.Println(fmt.Sprintf("\n abra app deploy %s", internal.Domain)) + fmt.Printf("\n abra app deploy %s\n", internal.Domain) if len(secrets) > 0 { fmt.Println("") diff --git a/cli/cli.go b/cli/cli.go index 627a60bd..e33a4d12 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -80,29 +80,26 @@ Example: switch shellType { case "bash": - fmt.Println(fmt.Sprintf(` -# Run the following commands to install auto-completion + fmt.Printf(`# Run the following commands to install auto-completion sudo mkdir /etc/bash_completion.d/ sudo cp %s /etc/bash_completion.d/abra echo "source /etc/bash_completion.d/abra" >> ~/.bashrc # To test, run the following: "abra app " - you should see command completion! -`, autocompletionFile)) +`, autocompletionFile) case "zsh": - fmt.Println(fmt.Sprintf(` -# Run the following commands to install auto-completion + fmt.Printf(`# Run the following commands to install auto-completion sudo mkdir /etc/zsh/completion.d/ sudo cp %s /etc/zsh/completion.d/abra echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc # To test, run the following: "abra app " - you should see command completion! -`, autocompletionFile)) +`, autocompletionFile) case "fish": - fmt.Println(fmt.Sprintf(` -# Run the following commands to install auto-completion + fmt.Printf(`# Run the following commands to install auto-completion sudo mkdir -p /etc/fish/completions sudo cp %s /etc/fish/completions/abra echo "source /etc/fish/completions/abra" >> ~/.config/fish/config.fish # To test, run the following: "abra app " - you should see command completion! -`, autocompletionFile)) +`, autocompletionFile) } return nil diff --git a/cli/recipe/new.go b/cli/recipe/new.go index 87e84d87..346a5426 100644 --- a/cli/recipe/new.go +++ b/cli/recipe/new.go @@ -103,7 +103,7 @@ recipe and domain in the sample environment config). logrus.Fatal(err) } - fmt.Print(fmt.Sprintf(` + fmt.Printf(` Your new %s recipe has been created in %s. In order to share your recipe, you can upload it the git repository to: @@ -118,7 +118,7 @@ See "abra recipe -h" for additional recipe maintainer commands. Happy Hacking! -`, recipeName, path.Join(config.RECIPES_DIR, recipeName), recipeName)) +`, recipeName, path.Join(config.RECIPES_DIR, recipeName), recipeName) return nil }, diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index d5b4ad00..a89b917d 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -68,7 +68,7 @@ local file system. if internal.NoInput { logrus.Fatalf("unable to continue, input required for initial version") } - fmt.Println(fmt.Sprintf(` + fmt.Printf(` The following options are two types of initial semantic version that you can pick for %s that will be published in the recipe catalogue. This follows the semver convention (more on https://semver.org), here is a short cheatsheet @@ -85,7 +85,7 @@ If you want people to be able alpha test your current config for %s but don't think it is quite reliable, go with 0.1.0 and people will know that things are likely to change. -`, recipe.Name, recipe.Name)) +`, recipe.Name, recipe.Name) var chosenVersion string edPrompt := &survey.Select{ Message: "which version do you want to begin with?",