From bb818fdb404d8250a47dc4d540c5d182527dc5bf Mon Sep 17 00:00:00 2001 From: Volker Schukai <volker.schukai@schukai.com> Date: Thu, 13 Oct 2022 17:04:04 +0200 Subject: [PATCH] refactor the execute function, the execute function should not print messages --- api.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/api.go b/api.go index a480886..4b4cc8d 100644 --- a/api.go +++ b/api.go @@ -14,32 +14,14 @@ import ( // ExecuteWithShadow executes the command line arguments and calls the functions. func ExecuteWithShadow[C any, D any](cmd C, cnf D) *Settings[C] { - s := execute(cmd, cnf, os.Args[0], os.Args[1:]) - - if s.HasErrors() { - for _, e := range s.Errors() { - fmt.Println(e) - } - } - return s + return execute(cmd, cnf, os.Args[0], os.Args[1:]) } type noShadow struct{} // Execute executes the command line arguments and calls the functions. func Execute[C any](cmd C) *Settings[C] { - s := execute(cmd, noShadow{}, os.Args[0], os.Args[1:]) - if s.HasErrors() { - for _, e := range s.Errors() { - fmt.Println(e) - } - } - - if s.hint != "" { - fmt.Println(s.hint) - } - - return s + return execute(cmd, noShadow{}, os.Args[0], os.Args[1:]) } func (s *Settings[C]) PrintFlagOutput() { -- GitLab