Skip to content

Commit

Permalink
refactor(userctl): rename user callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Jan 20, 2024
1 parent a37b1cf commit 71e9117
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/userctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def run_cmd(msg: str | None, cmd: Sequence[str], input: str | None = None) -> st
return subprocess.check_output(cmd, **cmd_kwargs).decode("utf-8").rstrip("\n")


def check_email(user: str):
if not user.endswith("@uni-trier.de"):
def generate_username(email: str):
if not email.endswith("@uni-trier.de"):
typer.confirm(
"You did not provide a university email address. This is only recommended for external users. Continue?",
abort=True,
)

return user.lower().split("@")[0]
return email.lower().split("@")[0]


def zfs_options(kwargs: Mapping[str, str], prefix: Optional[str] = None) -> list[str]:
Expand All @@ -65,7 +65,7 @@ def homedir_zfs(user: str) -> str:
def add(
user: Annotated[
str,
typer.Argument(callback=check_email),
typer.Argument(callback=generate_username),
],
full_name: str,
expire_date: Annotated[
Expand Down Expand Up @@ -156,7 +156,7 @@ def add(
def remove(
user: Annotated[
str,
typer.Argument(callback=check_email),
typer.Argument(callback=generate_username),
],
force: bool = False,
keep_home: bool = False,
Expand Down Expand Up @@ -185,7 +185,7 @@ def remove(
def edit(
user: Annotated[
str,
typer.Argument(callback=check_email),
typer.Argument(callback=generate_username),
],
expire_date: Annotated[
Optional[datetime],
Expand Down

0 comments on commit 71e9117

Please sign in to comment.