This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: support --force for all commands that allow output flags
Somewhat consolidates this logic. Add tests for each for completeness (because not all codepaths are the same). Change-Id: If6296eef1bfd4f36a755546c9bb4de21a4c40cbc Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9567 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
- Loading branch information
Showing
9 changed files
with
85 additions
and
6 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
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
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,19 @@ | ||
# Verify that def with --force works | ||
|
||
# First time should simply succeed | ||
cue def -o test.cue file.cue | ||
cmp test.cue file.cue | ||
|
||
# Second time will fail without --force | ||
! cue def -o test.cue file.cue | ||
stderr 'error writing "test.cue": file already exists' | ||
|
||
# Second time with --force should succeed | ||
cue def --force -o test.cue file.cue | ||
cmp test.cue file.cue | ||
|
||
-- file.cue -- | ||
package hello | ||
|
||
#who: "World" | ||
message: "Hello \(#who)!" |
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,22 @@ | ||
# Verify that eval with --force works | ||
|
||
# First time should simply succeed | ||
cue eval -o eval.cue file.cue | ||
cmp eval.cue eval.golden | ||
|
||
# Second time will fail without --force | ||
! cue eval -o eval.cue file.cue | ||
stderr 'error writing "eval.cue": file already exists' | ||
|
||
# Second time with --force should succeed | ||
cue eval --force -o eval.cue file.cue | ||
cmp eval.cue eval.golden | ||
|
||
-- file.cue -- | ||
package hello | ||
|
||
#who: "World" | ||
message: "Hello \(#who)!" | ||
-- eval.golden -- | ||
#who: "World" | ||
message: "Hello World!" |
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,21 @@ | ||
# Verify that export with --force works | ||
|
||
# First time should simply succeed | ||
cue export -o test.yml file.cue | ||
cmp test.yml test.yml.golden | ||
|
||
# Second time will fail without --force | ||
! cue export -o test.yml file.cue | ||
stderr 'error writing "test.yml": file already exists' | ||
|
||
# Second time with --force should succeed | ||
cue export --force -o test.yml file.cue | ||
cmp test.yml test.yml.golden | ||
|
||
-- file.cue -- | ||
package hello | ||
|
||
#who: "World" | ||
message: "Hello \(#who)!" | ||
-- test.yml.golden -- | ||
message: Hello World! |
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,19 @@ | ||
# Verify that trim with --force works | ||
|
||
# First time should simply succeed | ||
cue trim -o test.cue file.cue | ||
cmp test.cue file.cue | ||
|
||
# Second time will fail without --force | ||
! cue trim -o test.cue file.cue | ||
stderr 'error writing "test.cue": file already exists' | ||
|
||
# Second time with --force should succeed | ||
cue trim --force -o test.cue file.cue | ||
cmp test.cue file.cue | ||
|
||
-- file.cue -- | ||
package hello | ||
|
||
#who: "World" | ||
message: "Hello \(#who)!" |
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