Stop vctx format scan at --; limit raw to vault read
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ Without `--format`, `vctx` sets `VAULT_FORMAT` from the vault command:
|
||||
|
||||
It is left alone when `VAULT_FORMAT` is already set in the environment or the
|
||||
vault args include `-format` or `-field`. `--format` (`table`, `json`, `yaml`,
|
||||
`pretty`, `raw`) always sets it.
|
||||
`pretty`; `raw` for `vault read` only) always sets it.
|
||||
|
||||
## Flags
|
||||
|
||||
|
||||
+6
-2
@@ -68,7 +68,7 @@ func newRootCmd() *cobra.Command {
|
||||
})
|
||||
root.Flags().StringVar(&format, "format", "", "VAULT_FORMAT for this call (default: picked from the vault command)")
|
||||
_ = root.RegisterFlagCompletionFunc("format", cobra.FixedCompletions(
|
||||
[]string{"table", "json", "yaml", "pretty", "raw"}, cobra.ShellCompDirectiveNoFileComp))
|
||||
[]string{"table", "json", "yaml", "pretty"}, cobra.ShellCompDirectiveNoFileComp))
|
||||
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "version",
|
||||
@@ -166,7 +166,11 @@ func autoFormat(args, baseEnv []string) string {
|
||||
}
|
||||
}
|
||||
var pos []string
|
||||
for _, a := range args {
|
||||
for i, a := range args {
|
||||
if a == "--" {
|
||||
pos = append(pos, args[i+1:]...)
|
||||
break
|
||||
}
|
||||
name, _, _ := strings.Cut(strings.TrimLeft(a, "-"), "=")
|
||||
switch {
|
||||
case !strings.HasPrefix(a, "-"):
|
||||
|
||||
@@ -214,6 +214,7 @@ func TestAutoFormat(t *testing.T) {
|
||||
{[]string{"kv", "get", "-format=json", "kv/foo"}, nil, ""},
|
||||
{[]string{"read", "--format", "json", "aws/creds/role"}, nil, ""},
|
||||
{[]string{"kv", "get", "-field=password", "kv/foo"}, nil, ""},
|
||||
{[]string{"kv", "get", "--", "-format=json"}, nil, "yaml"},
|
||||
{[]string{"kv", "get", "kv/foo"}, []string{"VAULT_FORMAT=json"}, ""},
|
||||
{[]string{"kv", "get", "kv/foo"}, []string{"VAULT_FORMAT="}, "yaml"},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user