forked from TrueCloudLab/frostfs-node
[#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 <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
3627b44e92
commit
cc3f762cf2
2 changed files with 12 additions and 4 deletions
|
@ -11,9 +11,9 @@ import (
|
||||||
// values and their usage descriptions.
|
// values and their usage descriptions.
|
||||||
const (
|
const (
|
||||||
GenerateKey = "generate-key"
|
GenerateKey = "generate-key"
|
||||||
generateKeyShorthand = "g"
|
GenerateKeyShorthand = "g"
|
||||||
generateKeyDefault = false
|
GenerateKeyDefault = false
|
||||||
generateKeyUsage = "Generate new private key"
|
GenerateKeyUsage = "Generate new private key"
|
||||||
|
|
||||||
WalletPath = "wallet"
|
WalletPath = "wallet"
|
||||||
WalletPathShorthand = "w"
|
WalletPathShorthand = "w"
|
||||||
|
@ -72,7 +72,7 @@ func Init(cmd *cobra.Command) {
|
||||||
func InitWithoutRPC(cmd *cobra.Command) {
|
func InitWithoutRPC(cmd *cobra.Command) {
|
||||||
ff := cmd.Flags()
|
ff := cmd.Flags()
|
||||||
|
|
||||||
ff.BoolP(GenerateKey, generateKeyShorthand, generateKeyDefault, generateKeyUsage)
|
ff.BoolP(GenerateKey, GenerateKeyShorthand, GenerateKeyDefault, GenerateKeyUsage)
|
||||||
ff.StringP(WalletPath, WalletPathShorthand, WalletPathDefault, WalletPathUsage)
|
ff.StringP(WalletPath, WalletPathShorthand, WalletPathDefault, WalletPathUsage)
|
||||||
ff.StringP(Account, AccountShorthand, AccountDefault, AccountUsage)
|
ff.StringP(Account, AccountShorthand, AccountDefault, AccountUsage)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ const (
|
||||||
flagListPrintAttr = "with-attr"
|
flagListPrintAttr = "with-attr"
|
||||||
flagListContainerOwner = "owner"
|
flagListContainerOwner = "owner"
|
||||||
flagListName = "name"
|
flagListName = "name"
|
||||||
|
|
||||||
|
generateKeyContainerUsage = commonflags.GenerateKeyUsage + ", should be used with --owner flag"
|
||||||
)
|
)
|
||||||
|
|
||||||
// flag vars of list command.
|
// flag vars of list command.
|
||||||
|
@ -34,6 +36,11 @@ var listContainersCmd = &cobra.Command{
|
||||||
Run: func(cmd *cobra.Command, _ []string) {
|
Run: func(cmd *cobra.Command, _ []string) {
|
||||||
var idUser user.ID
|
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)
|
key := key.GetOrGenerate(cmd)
|
||||||
|
|
||||||
if flagVarListContainerOwner == "" {
|
if flagVarListContainerOwner == "" {
|
||||||
|
@ -104,4 +111,5 @@ func initContainerListContainersCmd() {
|
||||||
flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false,
|
flags.BoolVar(&flagVarListPrintAttr, flagListPrintAttr, false,
|
||||||
"Request and print attributes of each container",
|
"Request and print attributes of each container",
|
||||||
)
|
)
|
||||||
|
flags.Lookup(commonflags.GenerateKey).Usage = generateKeyContainerUsage
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue