From b07010e42b49af5773e9670f9f00d8b6c34ac95b Mon Sep 17 00:00:00 2001 From: Raul Catalinas <105791463+RaulCatalinas@users.noreply.github.com> Date: Sun, 8 Dec 2024 01:33:20 +0100 Subject: [PATCH 1/3] perf: optimize "ShowHelp" using "strings.Builder" - Replaced multiple "fmt.Print" statements with "strings.Builder" for efficient output. --- internal/cli/show_help.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/internal/cli/show_help.go b/internal/cli/show_help.go index ccaf41f..b05bc67 100644 --- a/internal/cli/show_help.go +++ b/internal/cli/show_help.go @@ -2,18 +2,29 @@ package cli import ( "fmt" + "strings" "github.com/RaulCatalinas/HuskyBC/internal/types" ) func ShowHelp(options []types.Option) { - fmt.Print("Usage: huskybc [options]\n\n") - fmt.Print("Command line for easy Husky configuration\n\n") - fmt.Println("Options:") + var builder strings.Builder + + builder.WriteString("Usage: huskybc [options]\n\n") + builder.WriteString("Command line for easy Husky configuration\n\n") + builder.WriteString("Options:\n") for _, option := range options { - fmt.Printf("%-15s %-5s %s\n", option.Name, option.Alias, option.Description) + fmt.Fprintf( + &builder, + "%-15s %-5s %s\n", + option.Name, + option.Alias, + option.Description, + ) } - fmt.Println() + builder.WriteString("\n") + + fmt.Print(builder.String()) } From 4d2215e170e83a901e99dfe5f0bbe072a3c8edf4 Mon Sep 17 00:00:00 2001 From: Raul Catalinas <105791463+RaulCatalinas@users.noreply.github.com> Date: Sun, 8 Dec 2024 01:34:13 +0100 Subject: [PATCH 2/3] chore: Unnecessary waiting time removed --- internal/handlers/handlers_options.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/handlers/handlers_options.go b/internal/handlers/handlers_options.go index 558255f..0dcfe20 100644 --- a/internal/handlers/handlers_options.go +++ b/internal/handlers/handlers_options.go @@ -2,7 +2,6 @@ package handlers import ( "os" - "time" "github.com/RaulCatalinas/HuskyBC/internal/constants" "github.com/RaulCatalinas/HuskyBC/internal/enums" @@ -18,11 +17,7 @@ func HandlerOptionCollaborate() { Message: "Opening the GitHub repository...", }) - time.Sleep(5 * time.Millisecond) - - err := webbrowser.Open(constants.REPOSITORY) - - if err != nil { + if err := webbrowser.Open(constants.REPOSITORY); err != nil { utils.WriteMessage(utils.WriteMessageProps{ Type: enums.MessageTypeError, Message: errorMessages.PROCESS_ERROR_MESSAGES[enums.GitHubRepoOpenError], From c4fcbc0b55ef45becec19819a20d60a5dcea978e Mon Sep 17 00:00:00 2001 From: Raul Catalinas <105791463+RaulCatalinas@users.noreply.github.com> Date: Sun, 8 Dec 2024 01:35:13 +0100 Subject: [PATCH 3/3] chore: Updated "settings.json" file --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 57bb5c7..03ccb06 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "MD029": false }, "cSpell.words": [ - "Checkin" + "Checkin", + "webbrowser" ] }