mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-31 18:48:08 +00:00
command/read
This commit is contained in:
@@ -25,8 +25,8 @@ func (c *ReadCommand) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args = flags.Args()
|
args = flags.Args()
|
||||||
if len(args) != 1 {
|
if len(args) < 1 || len(args) > 2 {
|
||||||
c.Ui.Error("read expects one argument")
|
c.Ui.Error("read expects one or two arguments")
|
||||||
flags.Usage()
|
flags.Usage()
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -49,12 +49,10 @@ func (c *ReadCommand) Run(args []string) int {
|
|||||||
switch format {
|
switch format {
|
||||||
case "json":
|
case "json":
|
||||||
return c.formatJSON(secret)
|
return c.formatJSON(secret)
|
||||||
case "table-whitespace":
|
|
||||||
return c.formatTable(secret, true)
|
|
||||||
case "table":
|
case "table":
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
return c.formatTable(secret, false)
|
return c.formatTable(secret, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@@ -77,11 +75,8 @@ func (c *ReadCommand) formatJSON(s *api.Secret) int {
|
|||||||
func (c *ReadCommand) formatTable(s *api.Secret, whitespace bool) int {
|
func (c *ReadCommand) formatTable(s *api.Secret, whitespace bool) int {
|
||||||
config := columnize.DefaultConfig()
|
config := columnize.DefaultConfig()
|
||||||
config.Delim = "♨"
|
config.Delim = "♨"
|
||||||
config.Glue = " | "
|
|
||||||
config.Prefix = ""
|
|
||||||
if whitespace {
|
|
||||||
config.Glue = "\t"
|
config.Glue = "\t"
|
||||||
}
|
config.Prefix = ""
|
||||||
|
|
||||||
input := make([]string, 0, 5)
|
input := make([]string, 0, 5)
|
||||||
input = append(input, fmt.Sprintf("Key %s Value", config.Delim))
|
input = append(input, fmt.Sprintf("Key %s Value", config.Delim))
|
||||||
@@ -130,9 +125,8 @@ General Options:
|
|||||||
|
|
||||||
Read Options:
|
Read Options:
|
||||||
|
|
||||||
-format=table The format for output. By default it is a human
|
-format=table The format for output. By default it is a whitespace-
|
||||||
friendly table. This can also be table-whitespace,
|
delimited table. This can also be json.
|
||||||
json.
|
|
||||||
|
|
||||||
`
|
`
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
|
|||||||
Reference in New Issue
Block a user