From 1112b4f0300ea65057c15f9cae04b535b38a63e7 Mon Sep 17 00:00:00 2001 From: Viacheslav Gonkivskyi Date: Fri, 29 Sep 2023 12:37:19 +0300 Subject: [PATCH] rework handling of store flag --- cmd/rpc.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cmd/rpc.go b/cmd/rpc.go index 918b07712f..7ea0173795 100644 --- a/cmd/rpc.go +++ b/cmd/rpc.go @@ -23,7 +23,6 @@ const ( var ( requestURL string authTokenFlag string - storePath string ) func RPCFlags() *flag.FlagSet { @@ -44,13 +43,7 @@ func RPCFlags() *flag.FlagSet { ) storeFlag := NodeFlags().Lookup(nodeStoreFlag) - - fset.StringVar( - &storePath, - nodeStoreFlag, - "", - storeFlag.Usage, - ) + fset.AddFlag(storeFlag) return fset } @@ -60,6 +53,10 @@ func InitClient(cmd *cobra.Command, _ []string) error { } if authTokenFlag == "" { + storePath := "" + if cmd.Flag(nodeStoreFlag).Changed { + storePath = cmd.Flag(nodeStoreFlag).Value.String() + } token, err := getToken(storePath) if err != nil { return fmt.Errorf("cant get the access to the auth token: %v", err)