From d83411016a55932296755b20c4b02a8d0ebfd1b8 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 14 Oct 2020 15:36:27 +0300 Subject: [PATCH] [#25] Use `printVerbose` wrapper for one-line messages Signed-off-by: Alex Vanin --- cmd/neofs-cli/modules/root.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index ad156349..c0d5801d 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -101,7 +101,7 @@ func initConfig() { // If a config file is found, read it in. if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using config file:", viper.ConfigFileUsed()) + printVerbose("Using config file: %s", viper.ConfigFileUsed()) } } @@ -116,9 +116,7 @@ func getKey() (*ecdsa.PrivateKey, error) { return nil, errCantGenerateKey } - if verbose { - fmt.Println("Generating private key:", hex.EncodeToString(buf)) - } + printVerbose("Generating private key:", hex.EncodeToString(buf)) return crypto.UnmarshalPrivateKey(buf) } @@ -182,3 +180,9 @@ func ownerFromString(s string) (*owner.ID, error) { return id, nil } + +func printVerbose(format string, a ...interface{}) { + if verbose { + fmt.Printf(format+"\n", a...) + } +}