mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 17:23:35 +05:00
style: rename input functions
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -15,7 +15,7 @@ from kiauh.utils.constants import COLOR_CYAN, RESET_FORMAT
|
||||
from kiauh.utils.logger import Logger
|
||||
|
||||
|
||||
def get_user_confirm(question: str, default_choice=True) -> bool:
|
||||
def get_confirm(question: str, default_choice=True) -> bool:
|
||||
options_confirm = ["y", "yes"]
|
||||
options_decline = ["n", "no"]
|
||||
|
||||
@@ -41,7 +41,7 @@ def get_user_confirm(question: str, default_choice=True) -> bool:
|
||||
Logger.print_error("Invalid choice. Please select 'y' or 'n'.")
|
||||
|
||||
|
||||
def get_user_number_input(
|
||||
def get_number_input(
|
||||
question: str, min_count: int, max_count=None, default=None
|
||||
) -> int:
|
||||
_question = question + f" (default={default})" if default else question
|
||||
@@ -65,7 +65,7 @@ def get_user_number_input(
|
||||
Logger.print_error("Invalid choice. Please select a valid number.")
|
||||
|
||||
|
||||
def get_user_string_input(question: str, exclude=Optional[List]) -> str:
|
||||
def get_string_input(question: str, exclude=Optional[List]) -> str:
|
||||
while True:
|
||||
_input = input(f"{COLOR_CYAN}###### {question}: {RESET_FORMAT}").strip()
|
||||
|
||||
@@ -77,7 +77,7 @@ def get_user_string_input(question: str, exclude=Optional[List]) -> str:
|
||||
Logger.print_error("This value is already in use/reserved.")
|
||||
|
||||
|
||||
def get_user_selection_input(question: str, option_list: List) -> str:
|
||||
def get_selection_input(question: str, option_list: List) -> str:
|
||||
while True:
|
||||
_input = input(f"{COLOR_CYAN}###### {question}: {RESET_FORMAT}").strip()
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from kiauh.utils.constants import COLOR_RED, RESET_FORMAT
|
||||
from kiauh.utils.input_utils import get_user_confirm
|
||||
from kiauh.utils.input_utils import get_confirm
|
||||
from kiauh.utils.logger import Logger
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ def clone_repo(target_dir: Path, url: str, branch: str) -> None:
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error cloning repository:", e.output.decode())
|
||||
else:
|
||||
overwrite_target = get_user_confirm(
|
||||
"Target directory already exists. Overwrite?"
|
||||
)
|
||||
overwrite_target = get_confirm("Target directory already exists. Overwrite?")
|
||||
if overwrite_target:
|
||||
try:
|
||||
shutil.rmtree(target_dir)
|
||||
@@ -98,7 +96,7 @@ def create_python_venv(target: Path) -> None:
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error setting up virtualenv:", e.output.decode())
|
||||
else:
|
||||
overwrite_venv = get_user_confirm("Virtualenv already exists. Re-create?")
|
||||
overwrite_venv = get_confirm("Virtualenv already exists. Re-create?")
|
||||
if overwrite_venv:
|
||||
try:
|
||||
shutil.rmtree(target)
|
||||
|
||||
Reference in New Issue
Block a user