update help text / flags

This commit is contained in:
Jason Swank 2024-12-12 20:38:53 -05:00
parent 3fbd407254
commit 0cc84183c3

View File

@ -13,9 +13,7 @@ import (
"aws-mgmt/pkg/client" "aws-mgmt/pkg/client"
) )
const secretsDesc = `View secrets from AWS Secrets Manager. const secretsDesc = `View secrets from AWS Secrets Manager.`
`
var SecretsApp = &cli.App{ var SecretsApp = &cli.App{
Name: "secrets", Name: "secrets",
@ -26,20 +24,7 @@ var SecretsApp = &cli.App{
ArgsUsage: "[secret]", ArgsUsage: "[secret]",
Action: secretsFunc, Action: secretsFunc,
Description: secretsDesc, Description: secretsDesc,
Flags: []cli.Flag{ Flags: flags,
&cli.BoolFlag{
Name: "totp",
Usage: "Generate a MFA token based on the secret value",
},
&cli.StringSliceFlag{
Name: "tags",
Usage: "Tags in the format key=value",
},
&cli.BoolFlag{
Name: "sh",
Usage: "Print the equivalent AWS CLI / shell command(s)",
},
},
} }
var SecretsCommand = &cli.Command{ var SecretsCommand = &cli.Command{
@ -51,15 +36,21 @@ var SecretsCommand = &cli.Command{
ArgsUsage: "[secret]", ArgsUsage: "[secret]",
Action: secretsFunc, Action: secretsFunc,
Description: secretsDesc, Description: secretsDesc,
Flags: []cli.Flag{ Flags: flags,
&cli.BoolFlag{ }
Name: "totp",
Usage: "Return a MFA token", var flags = []cli.Flag{
}, &cli.BoolFlag{
&cli.StringSliceFlag{ Name: "sh",
Name: "tags", Usage: "Print the equivalent AWS CLI / shell command(s) to stderr",
Usage: "Tags in the format key=value", },
}, &cli.StringSliceFlag{
Name: "tags",
Usage: "Specify tags to filter secrets, like --tags type=totp",
},
&cli.BoolFlag{
Name: "totp",
Usage: "Generate a MFA token based on the secret value",
}, },
} }
@ -113,15 +104,13 @@ func secretsFunc(c *cli.Context) error {
} else { } else {
// print the aws cli equivalent command to output this secret to stderr // print the aws cli equivalent command to output this secret to stderr
if c.Bool("sh") { if c.Bool("sh") {
fmt.Fprintln(os.Stderr, fmt.Sprintf("aws secretsmanager get-secret-value --secret-id %s --query SecretString --output text --no-cli-pager",secret)) fmt.Fprintln(os.Stderr, fmt.Sprintf("aws secretsmanager get-secret-value --secret-id %s --query SecretString --output text --no-cli-pager", secret))
} }
fmt.Println(secretValue) fmt.Println(secretValue)
} }
return nil return nil
} }
func parseTags(rawTags []string) map[string]string { func parseTags(rawTags []string) map[string]string {
tags := make(map[string]string) tags := make(map[string]string)
for _, tag := range rawTags { for _, tag := range rawTags {