From 67af4c89a887184ce3b21d809f01b244ee31c23f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 11 Aug 2022 10:30:45 +0400 Subject: [PATCH] [#1649] cli: Refactor `--owner` flag definition in `container list` cmd Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/container/list.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/neofs-cli/modules/container/list.go b/cmd/neofs-cli/modules/container/list.go index fbb80aace..e1e495db4 100644 --- a/cmd/neofs-cli/modules/container/list.go +++ b/cmd/neofs-cli/modules/container/list.go @@ -14,16 +14,16 @@ import ( // flags of list command const ( - flagListPrintAttr = "with-attr" + flagListPrintAttr = "with-attr" + flagListContainerOwner = "owner" ) // flag vars of list command var ( - flagVarListPrintAttr bool + flagVarListPrintAttr bool + flagVarListContainerOwner string ) -var containerOwner string - var listContainersCmd = &cobra.Command{ Use: "list", Short: "List all created containers", @@ -33,10 +33,10 @@ var listContainersCmd = &cobra.Command{ key := key.GetOrGenerate(cmd) - if containerOwner == "" { + if flagVarListContainerOwner == "" { user.IDFromKey(&idUser, key.PublicKey) } else { - err := idUser.DecodeString(containerOwner) + err := idUser.DecodeString(flagVarListContainerOwner) common.ExitOnErr(cmd, "invalid user ID: %w", err) } @@ -80,7 +80,9 @@ func initContainerListContainersCmd() { flags := listContainersCmd.Flags() - flags.StringVar(&containerOwner, "owner", "", "owner of containers (omit to use owner from private key)") + flags.StringVar(&flagVarListContainerOwner, flagListContainerOwner, "", + "owner of containers (omit to use owner from private key)", + ) flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false, "request and print attributes of each container", )