Skip to content

prompt

This module contains prompts used when creating a ssb-project.

choose_login(path)

Asks the user to pick between stored GitHub usernames.

If GitHub credentials are not found users is promoted to input PAT.

Parameters:

Name Type Description Default
path Path

Path to folder containing GitHub credentials

required

Returns:

Name Type Description
str str

GitHub personal access token

Source code in ssb_project_cli/ssb_project/create/prompt.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def choose_login(path: Path) -> str:
    """Asks the user to pick between stored GitHub usernames.

    If GitHub credentials are not found users is promoted to input PAT.

    Args:
        path: Path to folder containing GitHub credentials

    Returns:
        str: GitHub personal access token
    """
    user_token_dict: dict[str, str] = get_github_pat(path)

    if len(user_token_dict) == 1:
        return list(user_token_dict.values())[0]
    if user_token_dict:
        choice = questionary.select(
            "Select your GitHub account:", choices=user_token_dict.keys()  # type: ignore
        ).ask()
        return user_token_dict[choice]
    else:
        pat: str = questionary.password(
            "Enter your GitHub personal access token:"
        ).ask()
        return pat

request_name_email()

Requests name and email from user.

Returns:

Type Description
tuple[str, str]

tuple[str, str]: User supplied name and email

Source code in ssb_project_cli/ssb_project/create/prompt.py
11
12
13
14
15
16
17
18
19
def request_name_email() -> tuple[str, str]:
    """Requests name and email from user.

    Returns:
        tuple[str, str]: User supplied name and email
    """
    name = typer.prompt("Enter your full name: ")
    email = typer.prompt("Enter your email: ")
    return name, email

request_project_description()

Prompts the user for a project description.

Continues to prompt the user until a non-empty string is supplied.

Returns:

Name Type Description
str str

Project description

Source code in ssb_project_cli/ssb_project/create/prompt.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def request_project_description() -> str:
    """Prompts the user for a project description.

    Continues to prompt the user until a non-empty string is supplied.

    Returns:
         str: Project description
    """
    description: str = typer.prompt("Project description")

    if description == "":
        description = request_project_description()

    return description