Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Use preformatted strings in fmt help #7263

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cmd/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down