Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP rich-inquirer-replace #1778

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions plextraktsync/commands/plex_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]):
Expand All @@ -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:
Expand Down
Loading