From cc3f762cf29935bd06ee1c9c00ea1790703ba10d Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Tue, 28 May 2024 15:08:28 +0300 Subject: [PATCH] [#12] cli: clarify `-g` usage in `container list` Add usage replacement for `container list -g` and verbose warning when using `-g` without `--owner`. Signed-off-by: Ekaterina Lebedeva --- cmd/frostfs-cli/internal/commonflags/flags.go | 8 ++++---- cmd/frostfs-cli/modules/container/list.go | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/frostfs-cli/internal/commonflags/flags.go b/cmd/frostfs-cli/internal/commonflags/flags.go index 5049dc3b1..6915ef42b 100644 --- a/cmd/frostfs-cli/internal/commonflags/flags.go +++ b/cmd/frostfs-cli/internal/commonflags/flags.go @@ -11,9 +11,9 @@ import ( // values and their usage descriptions. const ( GenerateKey = "generate-key" - generateKeyShorthand = "g" - generateKeyDefault = false - generateKeyUsage = "Generate new private key" + GenerateKeyShorthand = "g" + GenerateKeyDefault = false + GenerateKeyUsage = "Generate new private key" WalletPath = "wallet" WalletPathShorthand = "w" @@ -72,7 +72,7 @@ func Init(cmd *cobra.Command) { func InitWithoutRPC(cmd *cobra.Command) { ff := cmd.Flags() - ff.BoolP(GenerateKey, generateKeyShorthand, generateKeyDefault, generateKeyUsage) + ff.BoolP(GenerateKey, GenerateKeyShorthand, GenerateKeyDefault, GenerateKeyUsage) ff.StringP(WalletPath, WalletPathShorthand, WalletPathDefault, WalletPathUsage) ff.StringP(Account, AccountShorthand, AccountDefault, AccountUsage) } diff --git a/cmd/frostfs-cli/modules/container/list.go b/cmd/frostfs-cli/modules/container/list.go index 8f5db49df..a1410d7a0 100644 --- a/cmd/frostfs-cli/modules/container/list.go +++ b/cmd/frostfs-cli/modules/container/list.go @@ -18,6 +18,8 @@ const ( flagListPrintAttr = "with-attr" flagListContainerOwner = "owner" flagListName = "name" + + generateKeyContainerUsage = commonflags.GenerateKeyUsage + ", should be used with --owner flag" ) // flag vars of list command. @@ -34,6 +36,11 @@ var listContainersCmd = &cobra.Command{ Run: func(cmd *cobra.Command, _ []string) { var idUser user.ID + generateKey, _ := cmd.Flags().GetBool(commonflags.GenerateKey) + if flagVarListContainerOwner == "" && generateKey { + cmd.PrintErrln("WARN: using -g without --owner - output will be empty") + } + key := key.GetOrGenerate(cmd) if flagVarListContainerOwner == "" { @@ -104,4 +111,5 @@ func initContainerListContainersCmd() { flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false, "Request and print attributes of each container", ) + flags.Lookup(commonflags.GenerateKey).Usage = generateKeyContainerUsage }