mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Formatter CLI: Provide option to suppress diff
This commit is contained in:
parent
1c8d7daea2
commit
84e529a4a8
1 changed files with 24 additions and 15 deletions
|
@ -90,6 +90,13 @@ class BlueprintApp:
|
|||
default=2,
|
||||
type=int,
|
||||
)
|
||||
format.add_argument(
|
||||
"-n",
|
||||
"--no-diff",
|
||||
help="Do not print a full diff of the changes",
|
||||
default=False,
|
||||
action="store_true",
|
||||
)
|
||||
format.add_argument(
|
||||
"inputs",
|
||||
nargs="+",
|
||||
|
@ -221,6 +228,7 @@ class BlueprintApp:
|
|||
file.write(formatted_str)
|
||||
happened = "Formatted"
|
||||
|
||||
if not opts.no_diff:
|
||||
diff_lines = []
|
||||
a_lines = data.splitlines(keepends=True)
|
||||
b_lines = formatted_str.splitlines(keepends=True)
|
||||
|
@ -238,6 +246,7 @@ class BlueprintApp:
|
|||
diff_lines.append("\\ No newline at end of file\n")
|
||||
|
||||
print("".join(diff_lines))
|
||||
|
||||
to_print = Colors.BOLD
|
||||
if errored:
|
||||
to_print += f"{Colors.RED}Skipped {file.name}: Will not overwrite file with compile errors"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue