From 1416197cdf7c1e1155f7f09b45aa850c987364d6 Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 19 Aug 2025 17:19:23 +0200 Subject: [PATCH 1/2] implement __repr__ for Project --- golioth/golioth.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/golioth/golioth.py b/golioth/golioth.py index 6014abd..62a1b89 100644 --- a/golioth/golioth.py +++ b/golioth/golioth.py @@ -160,6 +160,9 @@ def __init__(self, client: Client, info: dict[str, Any]): self.ota_events: ProjectOTAEvents = ProjectOTAEvents(self) self.tags: ProjectTags = ProjectTags(self) + def __repr__(self) -> str: + return f'Project ' + @property def headers(self) -> Dict[str, str]: return self.client.headers From ef4de4da3f08f45e61db3e2ef9736a3a7912668c Mon Sep 17 00:00:00 2001 From: Marcin Niestroj Date: Tue, 19 Aug 2025 17:19:54 +0200 Subject: [PATCH 2/2] cli: add 'projects list' command --- golioth/cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/golioth/cli.py b/golioth/cli.py index 248d7e4..852678f 100755 --- a/golioth/cli.py +++ b/golioth/cli.py @@ -1041,6 +1041,24 @@ async def delete(config, tag_id): sys.exit(1) +@cli.group() +def projects(): + """Projects related commands.""" + pass + + +@projects.command() +@pass_config +async def list(config): + """List projects.""" + with console.status('Getting projects...'): + client = Client(api_url = config.api_url, api_key = config.api_key, access_token = config.access_token) + projects = await client.get_projects() + + for p in projects: + print(p) + + def main(): cli(_anyio_backend='trio')