From 6de4565f4dfad27bbaf8551f1a64ee353c6c51a0 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Tue, 14 Jan 2025 16:23:30 +0000 Subject: [PATCH] docs: Use preformatted strings in fmt help (#7263) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this, the `--` are rendered in HTML as `–` making the commands with flags incorrect in the docs. Signed-off-by: Charlie Egan --- cmd/fmt.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/fmt.go b/cmd/fmt.go index e9bb13a3cf..fc9a9c3985 100644 --- a/cmd/fmt.go +++ b/cmd/fmt.go @@ -75,18 +75,18 @@ code if a file would be reformatted. The 'fmt' command can be run in several compatibility modes for consuming and outputting different Rego versions: -* 'opa fmt': +* ` + "`" + `opa fmt` + "`" + `: * v1 Rego is formatted to v1 - * 'rego.v1'/'future.keywords' imports are NOT removed - * 'rego.v1'/'future.keywords' imports are NOT added if missing + * ` + "`" + `rego.v1` + "`" + `/` + "`" + `future.keywords` + "`" + ` imports are NOT removed + * ` + "`" + `rego.v1` + "`" + `/` + "`" + `future.keywords` + "`" + ` imports are NOT added if missing * v0 rego is rejected -* 'opa fmt --v0-compatible': +* ` + "`" + `opa fmt --v0-compatible` + "`" + `: * v0 Rego is formatted to v0 * v1 Rego is rejected -* 'opa fmt --v0-v1': +* ` + "`" + `opa fmt --v0-v1` + "`" + `: * v0 Rego is formatted to be compatible with v0 AND v1 * v1 Rego is rejected -* 'opa fmt --v0-v1 --v1-compatible': +* ` + "`" + `opa fmt --v0-v1 --v1-compatible` + "`" + `: * v1 Rego is formatted to be compatible with v0 AND v1 * v0 Rego is rejected `, @@ -99,7 +99,6 @@ different Rego versions: } func opaFmt(args []string) int { - if len(args) == 0 { if err := formatStdin(&fmtParams, os.Stdin, os.Stdout); err != nil { fmt.Fprintln(os.Stderr, err) @@ -231,7 +230,6 @@ func formatFile(params *fmtCommandParams, out io.Writer, filename string, info o } func formatStdin(params *fmtCommandParams, r io.Reader, w io.Writer) error { - contents, err := io.ReadAll(r) if err != nil { return err