-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: add a fmt --check flag to list badly formatted files
Adds a --check flag that will cause cue to fail with exit code 1 in case any files require formatting. A list of non formatted files will be displayed, line by line, to stdout. Also, a typo is fixed in cue/ast/ast.go. fixes #363. Change-Id: I27c8e9b18bb01f981cd061a23ee3323bc403c9a9 Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
- Loading branch information
Showing
3 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# succeeds when file is formatted | ||
exec cue fmt --check formatted.cue | ||
|
||
stdin formatted.cue | ||
exec cue fmt --check - | ||
|
||
# fails and displays non formatted files | ||
! exec cue fmt --check not_formatted.cue another_not_formatted.cue | ||
cmpenv stdout expected-output | ||
|
||
# files are not modified with --check | ||
# running twice returns the same file list | ||
! exec cue fmt --check not_formatted.cue another_not_formatted.cue | ||
cmpenv stdout expected-output | ||
|
||
# stdin fails with no output | ||
stdin not_formatted.cue | ||
! exec cue fmt --check - | ||
! stdout . | ||
|
||
-- formatted.cue -- | ||
foo: "bar" | ||
-- not_formatted.cue -- | ||
foo: "bar" | ||
-- another_not_formatted.cue -- | ||
bar: "baz" | ||
x: 1 | ||
-- expected-output -- | ||
$WORK${/}another_not_formatted.cue | ||
$WORK${/}not_formatted.cue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters