dockge-cli/dockge_cli/components/exec.py
Firq 44ee9c7cad
All checks were successful
/ backend-pylint (push) Successful in 9s
Starting with CLI
2024-06-29 17:41:09 +02:00

32 lines
952 B
Python

from getpass import getpass
from urllib.parse import urlparse
from . import storage
def exec_command(command, extra_args):
match command:
case "login":
storage.set("username", input("Username: "), encoded=True)
storage.set("password", getpass("Password: "), encoded=True)
return
case "logout":
storage.remove("username")
storage.remove("password")
return
case "host":
if len(extra_args) > 0:
res = urlparse(extra_args[0])
if all([res.scheme, res.netloc]):
storage.set("host", extra_args[0])
else:
raise Exception(f"Malformed URL {extra_args[0]}")
return
print(storage.get("host"))
case "exit":
storage.clear()
return
case _:
print("Not implemented")
return