have io.write_text handle dry_run

This commit is contained in:
Paul Gauthier 2023-07-05 21:20:22 -07:00
parent b46dffbb20
commit 4ee5c49a04
2 changed files with 4 additions and 0 deletions

View file

@ -101,6 +101,7 @@ class InputOutput:
tool_output_color=None,
tool_error_color="red",
encoding="utf-8",
dry_run=False,
):
no_color = os.environ.get("NO_COLOR")
if no_color is not None and no_color != "":
@ -144,6 +145,8 @@ class InputOutput:
return
def write_text(self, filename, content):
if self.dry_run:
return
with open(str(filename), "w", encoding=self.encoding) as f:
f.write(content)

View file

@ -252,6 +252,7 @@ def main(args=None, input=None, output=None):
user_input_color=args.user_input_color,
tool_output_color=args.tool_output_color,
tool_error_color=args.tool_error_color,
dry_run=args.dry_run,
)
if args.verbose: