diff --git a/docs/searchindex.js b/docs/searchindex.js index cf3378f..21d1704 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["cli","index","stack_diff"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["cli.rst","index.rst","stack_diff.rst"],objects:{"stackdiff.StackDiff":{change_template:[2,1,1,""],render_changes:[2,2,1,""],render_differences:[2,2,1,""],stack_template:[2,1,1,""]},stackdiff:{StackDiff:[2,0,1,""]}},objnames:{"0":["py","class","Python class"],"1":["py","property","Python property"],"2":["py","method","Python method"]},objtypes:{"0":"py:class","1":"py:property","2":"py:method"},terms:{"3":1,"8":1,"class":2,"default":2,"import":2,"new":2,And:1,For:1,If:1,The:[0,1],To:2,acm:1,action:1,allow:1,amazon:[1,2],an:[1,2],appli:[0,2],arn:[0,2],ask:1,avail:1,aw:1,between:[0,2],boto3:2,bug:1,cariad:1,certificatemanag:1,chang:[0,1,2],change_templ:2,cli:1,cloudform:[0,1,2],com:1,consid:1,current:[0,2],deletecertif:1,deploy:1,describ:[1,2],describecertif:1,descript:1,differ:[0,2],eccleston:1,effect:1,engin:1,exampl:1,execut:[0,2],featur:1,foo:1,foodeploy:1,freelanc:1,get:2,github:1,ha:1,hello:1,i:1,iam:1,id:[0,1,2],independ:1,io:2,issu:1,later:1,licenc:1,ll:1,logic:1,m:1,me:1,mention:1,mit:1,my:1,name:[0,2],none:2,option:2,packag:1,paramet:2,pass:0,physic:1,pip:1,pleas:1,polici:1,policydocu:1,policynam:1,print:0,prioriti:1,properti:[1,2],propos:[0,2],python:1,question:1,rais:1,re:1,render:2,render_chang:2,render_differ:2,request:1,requestcertif:1,requir:1,resourc:1,respond:1,s:[0,2],script:2,servic:[1,2],session:2,set:[0,1,2],softwar:1,sourc:1,sponsor:1,stack:[0,1,2],stack_templ:2,stackdiff:[0,2],statement:1,str:2,templat:[0,2],thank:1,thi:0,tool:1,type:1,under:1,updat:1,usag:1,user:1,usernam:1,valu:1,visualis:[1,2],wa:2,web:[1,2],work:1,would:[0,2],writer:2,you:1,your:2},titles:["CLI usage","stackdiff","Python usage"],titleterms:{cli:0,content:1,feedback:1,instal:1,project:1,python:2,stackdiff:1,usag:[0,2]}}) \ No newline at end of file +Search.setIndex({docnames:["cli","index","stack_diff"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,sphinx:56},filenames:["cli.rst","index.rst","stack_diff.rst"],objects:{"stackdiff.StackDiff":{change_template:[2,1,1,""],render_changes:[2,2,1,""],render_differences:[2,2,1,""],stack_template:[2,1,1,""]},stackdiff:{StackDiff:[2,0,1,""]}},objnames:{"0":["py","class","Python class"],"1":["py","property","Python property"],"2":["py","method","Python method"]},objtypes:{"0":"py:class","1":"py:property","2":"py:method"},terms:{"3":1,"8":1,"class":2,"default":2,"import":2,"new":2,And:1,For:1,If:1,The:[0,1],To:2,acm:1,action:1,allow:1,amazon:[1,2],an:[1,2],appli:[0,2],arn:[0,2],ask:1,avail:1,aw:1,between:[0,2],boto3:2,bug:1,cariad:1,certificatemanag:1,chang:[0,1,2],change_templ:2,cli:1,cloudform:[0,1,2],com:1,consid:1,current:[0,2],deletecertif:1,deploy:1,describ:[1,2],describecertif:1,descript:1,differ:[0,2],eccleston:1,effect:1,engin:1,exampl:1,execut:[0,2],featur:1,foo:1,foodeploy:1,freelanc:1,get:2,github:1,ha:1,hello:1,i:1,iam:1,id:[0,1,2],independ:1,io:2,issu:1,later:1,licenc:1,ll:1,logic:1,m:1,me:1,mention:1,mit:1,my:1,name:[0,2],none:2,option:2,packag:1,paramet:2,pass:0,physic:1,pip:1,pleas:1,polici:1,policydocu:1,policynam:1,print:0,prioriti:1,properti:[1,2],propos:[0,2],python:1,question:1,rais:1,re:1,render:2,render_chang:2,render_differ:2,request:1,requestcertif:1,requir:1,resourc:1,respond:1,s:[0,2],script:2,servic:[1,2],session:2,set:[0,1,2],softwar:1,sourc:1,sponsor:1,stack:[0,1,2],stack_templ:2,stackdiff:[0,2],statement:1,stdout:2,str:2,templat:[0,2],thank:1,thi:0,tool:1,type:1,under:1,updat:1,usag:1,user:1,usernam:1,valu:1,visualis:[1,2],wa:2,web:[1,2],work:1,would:[0,2],writer:2,you:1,your:2},titles:["CLI usage","stackdiff","Python usage"],titleterms:{cli:0,content:1,feedback:1,instal:1,project:1,python:2,stackdiff:1,usag:[0,2]}}) \ No newline at end of file diff --git a/docs/stack_diff.html b/docs/stack_diff.html index c174139..d1d1b7d 100644 --- a/docs/stack_diff.html +++ b/docs/stack_diff.html @@ -208,23 +208,23 @@

Python usage
-render_changes(writer: IO[str]) None
+render_changes(writer: Optional[IO[str]] = None) None

Renders a visualisation of the changes that CloudFormation would apply if the change set was executed.

Parameters
-

writer – Writer

+

writer – Writer (defaults to stdout)

-render_differences(writer: IO[str]) None
+render_differences(writer: Optional[IO[str]] = None) None

Renders a visualisation of the differences between the stack’s current template and the change set’s proposed template.

Parameters
-

writer – Writer

+

writer – Writer (defaults to stdout)

diff --git a/stackdiff/stack_diff.py b/stackdiff/stack_diff.py index bd806f5..26c3f6d 100644 --- a/stackdiff/stack_diff.py +++ b/stackdiff/stack_diff.py @@ -1,4 +1,5 @@ from functools import cached_property +from sys import stdout from typing import IO, Optional from ansiscape import green, heavy, yellow @@ -57,13 +58,13 @@ def change_template(self) -> str: ) return response.get("TemplateBody", "") - def render_changes(self, writer: IO[str]) -> None: + def render_changes(self, writer: Optional[IO[str]] = None) -> None: """ Renders a visualisation of the changes that CloudFormation would apply if the change set was executed. Arguments: - writer: Writer + writer: Writer (defaults to ``stdout``) """ response = self.client.describe_change_set( @@ -109,18 +110,18 @@ def render_changes(self, writer: IO[str]) -> None: ) t = tabulate(rows, headers="firstrow", tablefmt="plain") - writer.write(t + "\n") + (writer or stdout).write(t + "\n") - def render_differences(self, writer: IO[str]) -> None: + def render_differences(self, writer: Optional[IO[str]] = None) -> None: """ Renders a visualisation of the differences between the stack's current template and the change set's proposed template. Arguments: - writer: Writer + writer: Writer (defaults to ``stdout``) """ - render(self.stack_template, self.change_template, writer) + render(self.stack_template, self.change_template, writer or stdout) @cached_property def stack_template(self) -> str: