Skip to content

Commit

Permalink
cmd: fix inspect to omit unnecessary whitespace
Browse files Browse the repository at this point in the history
Signed-off-by: Torin Sandall <[email protected]>
  • Loading branch information
tsandall committed Oct 26, 2023
1 parent 327ec14 commit 1e8cfc3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
15 changes: 10 additions & 5 deletions cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,16 @@ func printList(out io.Writer, list []listEntry, separator string) {
}
}
for _, e := range list {
line := fmt.Sprintf(" %s%s%s%s",
e.key,
separator,
strings.Repeat(" ", keyLength-len(e.key)),
e.value)
var line string
if len(e.value) > 0 {
line = fmt.Sprintf(" %s%s%s%s",
e.key,
separator,
strings.Repeat(" ", keyLength-len(e.key)),
e.value)
} else {
line = fmt.Sprintf(" %v", e.key)
}
fmt.Fprintln(out, truncateStr(line, pageWidth))
}
}
Expand Down
13 changes: 7 additions & 6 deletions cmd/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestDoInspect(t *testing.T) {
}

res := `{
"capabilities": {},
"manifest": {"revision": "rev", "roots": ["foo", "bar", "fuz", "baz", "a", "x"]},
"signatures_config": {},
"namespaces": {"data": ["/data.json"], "data.foo": ["/example/foo.rego"]}
Expand Down Expand Up @@ -300,7 +301,7 @@ Schemas:
input: {"type":"boolean"}
Related Resources:
https://pkg
https://pkg
https://pkg rr-pkg-note
Custom:
Expand All @@ -326,7 +327,7 @@ Schemas:
input: {"type":"integer"}
Related Resources:
https://doc
https://doc
https://doc rr-doc-note
Custom:
Expand All @@ -352,7 +353,7 @@ Schemas:
input: {"type":"string"}
Related Resources:
https://rule
https://rule
https://rule rr-rule-note
Custom:
Expand Down Expand Up @@ -493,7 +494,7 @@ Schemas:
input: {"type":"boolean"}
Related Resources:
https://pkg
https://pkg
https://pkg rr-pkg-note
Custom:
Expand Down Expand Up @@ -526,7 +527,7 @@ Schemas:
input: {"type":"integer"}
Related Resources:
https://doc
https://doc
https://doc rr-doc-note
Custom:
Expand All @@ -552,7 +553,7 @@ Schemas:
input: {"type":"string"}
Related Resources:
https://rule
https://rule
https://rule rr-rule-note
Custom:
Expand Down

0 comments on commit 1e8cfc3

Please sign in to comment.