From c2ecd7592ceeb9c4ff49c527384da9625e37c4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 31 Jan 2024 18:14:15 +0200 Subject: [PATCH] WIP rich-inquirer-replace --- plextraktsync/commands/plex_login.py | 45 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/plextraktsync/commands/plex_login.py b/plextraktsync/commands/plex_login.py index b769eb3cad..3bff412061 100644 --- a/plextraktsync/commands/plex_login.py +++ b/plextraktsync/commands/plex_login.py @@ -82,14 +82,17 @@ def choose_managed_user(account: MyPlexAccount): print(success("Managed user(s) found:")) users = sorted(users) users.insert(0, account.username) - user = inquirer.select( - message="Select the user you would like to use:", - choices=users, - default=None, - style=style, - qmark="", - pointer=">", - ).execute() + # user = inquirer.select( + # message="Select the user you would like to use:", + # choices=users, + # default=None, + # style=style, + # qmark="", + # pointer=">", + # ).execute() + # Prompt.choices() + user = Prompt.ask("Select the user you would like to use:", + choices=users, default=None) if user == account.username: return None @@ -111,7 +114,8 @@ def format_server(s): for c in s.connections: lines.append(f" {c.uri}") - return Choice(value=s.name, name="\n ".join(lines)) + # return Choice(value=s.name, name="\n ".join(lines)) + return f" {s.name}" + "\n ".join(lines) def prompt_server(servers: list[MyPlexResource]): @@ -121,22 +125,27 @@ def prompt_server(servers: list[MyPlexResource]): server_names = [] if owned_servers: - server_names.append(Separator("Owned servers")) + # server_names.append(Separator("Owned servers")) for s in sorter(owned_servers): server_names.append(format_server(s)) if unowned_servers: - server_names.append(Separator("Unowned servers")) + # server_names.append(Separator("Unowned servers")) for s in sorter(unowned_servers): server_names.append(format_server(s)) print() - return inquirer.select( - message="Select default server:", - choices=server_names, - default=None, - qmark="", - pointer=">", - ).execute() + # return inquirer.select( + # message="Select default server:", + # choices=server_names, + # default=None, + # qmark="", + # pointer=">", + # ).execute() + + server = Prompt.ask("Select default server:", + choices=server_names, default=None) + Prompt.choices + return server def pick_server(account: MyPlexAccount) -> MyPlexResource | None: