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') 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