From 49b734f92526fa8e6184ef5e9d9fa381023710f6 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Wed, 21 Aug 2024 12:17:37 +0100 Subject: [PATCH] small edit --- .../templates/executor/executor.go.gotmpl | 3 +- internal/executor/executor.go | 51 +++++++------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/cmd/enbas-codegen/templates/executor/executor.go.gotmpl b/cmd/enbas-codegen/templates/executor/executor.go.gotmpl index e57007b..8af05aa 100644 --- a/cmd/enbas-codegen/templates/executor/executor.go.gotmpl +++ b/cmd/enbas-codegen/templates/executor/executor.go.gotmpl @@ -139,8 +139,7 @@ func {{ $execute_command_function_name }}( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("({{ $name }}) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("({{ $name }}) unable to load configuration: " + err.Error() + ".") return err } diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 3e7f86f..bab0bdc 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -109,8 +109,7 @@ func ExecuteAcceptCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(accept) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(accept) unable to load configuration: " + err.Error() + ".") return err } @@ -183,8 +182,7 @@ func ExecuteAddCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(add) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(add) unable to load configuration: " + err.Error() + ".") return err } @@ -246,8 +244,7 @@ func ExecuteBlockCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(block) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(block) unable to load configuration: " + err.Error() + ".") return err } @@ -357,8 +354,7 @@ func ExecuteCreateCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(create) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(create) unable to load configuration: " + err.Error() + ".") return err } @@ -423,8 +419,7 @@ func ExecuteDeleteCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(delete) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(delete) unable to load configuration: " + err.Error() + ".") return err } @@ -498,8 +493,7 @@ func ExecuteEditCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(edit) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(edit) unable to load configuration: " + err.Error() + ".") return err } @@ -565,8 +559,7 @@ func ExecuteFollowCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(follow) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(follow) unable to load configuration: " + err.Error() + ".") return err } @@ -668,8 +661,7 @@ func ExecuteLoginCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(login) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(login) unable to load configuration: " + err.Error() + ".") return err } @@ -738,8 +730,7 @@ func ExecuteMuteCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(mute) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(mute) unable to load configuration: " + err.Error() + ".") return err } @@ -801,8 +792,7 @@ func ExecuteRejectCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(reject) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(reject) unable to load configuration: " + err.Error() + ".") return err } @@ -870,8 +860,7 @@ func ExecuteRemoveCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(remove) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(remove) unable to load configuration: " + err.Error() + ".") return err } @@ -972,8 +961,7 @@ func ExecuteShowCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(show) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(show) unable to load configuration: " + err.Error() + ".") return err } @@ -1035,8 +1023,7 @@ func ExecuteSwitchCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(switch) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(switch) unable to load configuration: " + err.Error() + ".") return err } @@ -1098,8 +1085,7 @@ func ExecuteUnblockCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(unblock) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(unblock) unable to load configuration: " + err.Error() + ".") return err } @@ -1161,8 +1147,7 @@ func ExecuteUnfollowCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(unfollow) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(unfollow) unable to load configuration: " + err.Error() + ".") return err } @@ -1226,8 +1211,7 @@ func ExecuteUnmuteCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(unmute) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(unmute) unable to load configuration: " + err.Error() + ".") return err } @@ -1329,8 +1313,7 @@ func ExecuteWhoamiCommand( // Load the configuration from file. exeConfig, err := config.NewConfigFromFile(exe.configDir) if err != nil { - tempPrinter := printer.NewPrinter(noColor, "", 0) - tempPrinter.PrintFailure("(whoami) unable to load configuration: " + err.Error() + ".") + printer.NewPrinter(noColor, "", 0).PrintFailure("(whoami) unable to load configuration: " + err.Error() + ".") return err }