|
1 | 1 | from functools import cached_property
|
| 2 | +from sys import stdout |
2 | 3 | from typing import IO, Optional
|
3 | 4 |
|
4 | 5 | from ansiscape import green, heavy, yellow
|
@@ -57,13 +58,13 @@ def change_template(self) -> str:
|
57 | 58 | )
|
58 | 59 | return response.get("TemplateBody", "")
|
59 | 60 |
|
60 |
| - def render_changes(self, writer: IO[str]) -> None: |
| 61 | + def render_changes(self, writer: Optional[IO[str]] = None) -> None: |
61 | 62 | """
|
62 | 63 | Renders a visualisation of the changes that CloudFormation would apply
|
63 | 64 | if the change set was executed.
|
64 | 65 |
|
65 | 66 | Arguments:
|
66 |
| - writer: Writer |
| 67 | + writer: Writer (defaults to ``stdout``) |
67 | 68 | """
|
68 | 69 |
|
69 | 70 | response = self.client.describe_change_set(
|
@@ -109,18 +110,18 @@ def render_changes(self, writer: IO[str]) -> None:
|
109 | 110 | )
|
110 | 111 |
|
111 | 112 | t = tabulate(rows, headers="firstrow", tablefmt="plain")
|
112 |
| - writer.write(t + "\n") |
| 113 | + (writer or stdout).write(t + "\n") |
113 | 114 |
|
114 |
| - def render_differences(self, writer: IO[str]) -> None: |
| 115 | + def render_differences(self, writer: Optional[IO[str]] = None) -> None: |
115 | 116 | """
|
116 | 117 | Renders a visualisation of the differences between the stack's current
|
117 | 118 | template and the change set's proposed template.
|
118 | 119 |
|
119 | 120 | Arguments:
|
120 |
| - writer: Writer |
| 121 | + writer: Writer (defaults to ``stdout``) |
121 | 122 | """
|
122 | 123 |
|
123 |
| - render(self.stack_template, self.change_template, writer) |
| 124 | + render(self.stack_template, self.change_template, writer or stdout) |
124 | 125 |
|
125 | 126 | @cached_property
|
126 | 127 | def stack_template(self) -> str:
|
|
0 commit comments