Skip to content

Commit 8c5a52c

Browse files
wedamijaandrewshie-sentry
authored andcommitted
feat(options): Add a default level of indentation when generating flagpole config (#89348)
Right now, we don't generate any indentation for our outputted flags. This is a little annoying when copying into options automator, since we need one level of indentation there. It's a bit error prone too, because it's easy to miss if you're just pasting in config. To work around this, just add a fake default top level key, and strip it out from the output.
1 parent c0d2d43 commit 8c5a52c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/flagpole/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ def to_dict(self) -> dict[str, Any]:
187187
return {self.name: dict_data}
188188

189189
def to_yaml_str(self) -> str:
190-
return yaml.dump(self.to_dict())
190+
# Add an extra level of indentation by adding a top level dummy config.
191+
# This makes it easier to paste the results into options automator
192+
dump = yaml.dump({"dummy": self.to_dict()})
193+
return "\n".join(dump.split("\n")[1:])
191194

192195
def to_json_str(self) -> str:
193196
return orjson.dumps(self.to_dict()).decode()

0 commit comments

Comments
 (0)