# succeeds when all files are well formatted
exec cue fmt --files --check standalone/a/

# prints files that are not well formatted, recursively
! exec cue fmt --files --check standalone/b
cmpenv stdout standalone/b/stdout-golden

# regular files can be passed as an argument with or without files
! exec cue fmt --files --check standalone/b/c/not-formatted.cue standalone/b/not-formatted.cue
cmpenv stdout standalone/b/stdout-golden

# file can be passed via stdin
stdin standalone/stdin/not-formatted.cue
! exec cue fmt --files --check -
cmpenv stdout standalone/stdin/stdout-check-golden

stdin standalone/stdin/not-formatted.cue
exec cue fmt --files -
cmpenv stdout standalone/stdin/stdout-golden

# current directory is used when no args provided
cd noargs
! exec cue fmt --files --check
cmpenv stdout stdout-golden
cd ..

# directories beginning with _ or . are ignored
exec cue fmt --files --check standalone/hidden/

# directories beginning with _ or . are processed when passed explicitly
! exec cue fmt --files --check standalone/hidden/_temp/ standalone/hidden/.temp/
cmpenv stdout standalone/hidden/stdin-golden

# files under cue.mod are ignored
exec cue fmt --files --check mod
! stdout .

# files under cue.mod are processed when passed explicitly
! exec cue fmt --files --check mod/cue.mod/
cmpenv stdout mod/stdout-golden

# exit early if user attempts to use ... patterns
! exec cue fmt --files --check standalone/a/...
stderr 'cannot use "..." in --files mode'
! stdout .
! exec cue fmt --files --check h...
stderr 'cannot use "..." in --files mode'
! stdout .

-- standalone/a/formatted.cue --
foo: "bar"
-- standalone/b/not-formatted.cue --
x:    1
-- standalone/b/c/not-formatted.cue --
foo:    "bar"
-- standalone/hidden/_temp/not-formatted.cue --
foo:    "bar"
-- standalone/hidden/.temp/not-formatted.cue --
foo:    "bar"
-- standalone/hidden/stdin-golden --
standalone${/}hidden${/}_temp${/}not-formatted.cue
standalone${/}hidden${/}.temp${/}not-formatted.cue
-- standalone/b/stdout-golden --
standalone${/}b${/}c${/}not-formatted.cue
standalone${/}b${/}not-formatted.cue
-- standalone/stdin/not-formatted.cue --
foo:    "bar"
-- standalone/stdin/stdout-golden --
foo: "bar"
-- standalone/stdin/stdout-check-golden --
-
-- mod/cue.mod/gen/not-formatted.cue --
foo:    "bar"
-- mod/cue.mod/usr/not-formatted.cue --
foo:    "bar"
-- mod/cue.mod/pkg/not-formatted.cue --
foo:    "bar"
-- mod/cue.mod/module.cue --
module: "example.com"
language: {
	version:        "v0.9.3"
}
-- mod/stdout-golden --
mod${/}cue.mod${/}gen${/}not-formatted.cue
mod${/}cue.mod${/}module.cue
mod${/}cue.mod${/}pkg${/}not-formatted.cue
mod${/}cue.mod${/}usr${/}not-formatted.cue
-- noargs/file.cue --
foo:    "bar"
-- noargs/dir/another-file.cue --
foo:    "bar"
-- noargs/stdout-golden --
dir${/}another-file.cue
file.cue