From 4768017be7309baa1167f051d4127e42a18110d5 Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Thu, 10 Apr 2025 14:32:40 -0700 Subject: [PATCH] feat(options): Add a default level of indentation when generating flagpole config 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. --- src/flagpole/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/flagpole/__init__.py b/src/flagpole/__init__.py index 57a1bb7c3be006..5533f86828ae19 100644 --- a/src/flagpole/__init__.py +++ b/src/flagpole/__init__.py @@ -187,7 +187,10 @@ def to_dict(self) -> dict[str, Any]: return {self.name: dict_data} def to_yaml_str(self) -> str: - return yaml.dump(self.to_dict()) + # Add an extra level of indentation by adding a top level dummy config. + # This makes it easier to paste the results into options automator + dump = yaml.dump({"dummy": self.to_dict()}) + return "\n".join(dump.split("\n")[1:]) def to_json_str(self) -> str: return orjson.dumps(self.to_dict()).decode()