Unverified Commit 24c9aa30 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

symphony/cli: add member list and add commands

parent 8265acfe
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
from typer import Typer from typer import Typer
from ..state import state from ..state import state
from ..utils import async_cli, print_namespace_table from ..utils import async_cli, print_namespace_table, print_members_table
app = Typer(help="Managing SimBricks namespaces.") app = Typer(help="Managing SimBricks namespaces.")
...@@ -83,3 +83,23 @@ async def delete(ident: int): ...@@ -83,3 +83,23 @@ async def delete(ident: int):
client = state.ns_client client = state.ns_client
await client.delete_ns(ident) await client.delete_ns(ident)
print(f"Deleted namespace with id {ident}.") print(f"Deleted namespace with id {ident}.")
@app.command()
@async_cli()
async def members():
"""List all members."""
client = state.ns_client
members = await client.get_members()
print_members_table(members)
@app.command()
@async_cli()
async def member_add(user: str, role: str):
"""Add member to namespace."""
client = state.ns_client
members = await client.add_member(role, user)
print(f"Added user {user} with role {role}.")
\ No newline at end of file
...@@ -99,3 +99,15 @@ def print_runner_table(runners): ...@@ -99,3 +99,15 @@ def print_runner_table(runners):
console = Console() console = Console()
console.print(table) console.print(table)
def print_members_table(members: dict[str, list[dict]]):
table = Table()
table.add_column("Role")
table.add_column("User")
table.add_column("First")
table.add_column("Last")
for r, ms in members.items():
for m in ms:
table.add_row(r, m['username'], m['first_name'], m['last_name'])
console = Console()
console.print(table)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment