[#12] cli: clarify -g
usage in container list
All checks were successful
DCO action / DCO (pull_request) Successful in 7m44s
Vulncheck / Vulncheck (pull_request) Successful in 9m38s
Build / Build Components (1.21) (pull_request) Successful in 10m2s
Build / Build Components (1.22) (pull_request) Successful in 10m0s
Tests and linters / Staticcheck (pull_request) Successful in 12m36s
Tests and linters / Lint (pull_request) Successful in 13m13s
Tests and linters / gopls check (pull_request) Successful in 15m17s
Pre-commit hooks / Pre-commit (pull_request) Successful in 16m16s
Tests and linters / Tests (1.21) (pull_request) Successful in 16m36s
Tests and linters / Tests with -race (pull_request) Successful in 16m36s
Tests and linters / Tests (1.22) (pull_request) Successful in 17m25s
All checks were successful
DCO action / DCO (pull_request) Successful in 7m44s
Vulncheck / Vulncheck (pull_request) Successful in 9m38s
Build / Build Components (1.21) (pull_request) Successful in 10m2s
Build / Build Components (1.22) (pull_request) Successful in 10m0s
Tests and linters / Staticcheck (pull_request) Successful in 12m36s
Tests and linters / Lint (pull_request) Successful in 13m13s
Tests and linters / gopls check (pull_request) Successful in 15m17s
Pre-commit hooks / Pre-commit (pull_request) Successful in 16m16s
Tests and linters / Tests (1.21) (pull_request) Successful in 16m36s
Tests and linters / Tests with -race (pull_request) Successful in 16m36s
Tests and linters / Tests (1.22) (pull_request) Successful in 17m25s
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.
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue