Loading src/cli/entrypoint.py +42 −2 Changes for src/cli/entrypoint.py: 42 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ from gitlab.v4.objects import ( Project as GitLabProject, User as GitLabUser, ) import questionary # Components from ..features.gitlab import GitLabFeature from ..prints.colors import Colors from ..prints.themes import Themes from ..system.platform import Platform from ..types.namespaces import Namespaces Loading Loading @@ -173,6 +175,30 @@ class Entrypoint: # Result return Entrypoint.Result.SUCCESS # Confirm @staticmethod def confirm(description: str, text: str = '') -> bool: # Header print( f'{Colors.BOLD} - Delete {description}: Confirm "' f'{Colors.RED}{text}' f'{Colors.BOLD}" deletion:' f'{Colors.RESET}', end='') Platform.flush() # Get user configuration answer: bool = questionary.confirm( message='', default=False, qmark='', style=Themes.confirmation_style(), auto_enter=True, ).ask() # Result return answer # Group @staticmethod def group( Loading Loading @@ -205,8 +231,15 @@ class Entrypoint: f'{Colors.RESET}') Platform.flush() # Delete group # Delete group after validation if options.delete_group: if not Entrypoint.confirm( group_type, group.full_path, ): return Entrypoint.Result.SUCCESS # Delete group gitlab.group_delete(criteria) print(f'{Colors.BOLD} - Delete {group_type}: ' f'{Colors.GREEN}Success' Loading Loading @@ -289,8 +322,15 @@ class Entrypoint: f'{Colors.RESET}') Platform.flush() # Delete project # Delete project after validation if options.delete_project: if not Entrypoint.confirm( 'project', project.path_with_namespace, ): return Entrypoint.Result.SUCCESS # Delete project gitlab.project_delete(criteria) print(f'{Colors.BOLD} - Delete project: ' f'{Colors.GREEN}Success' Loading src/prints/themes.py 0 → 100644 +60 −0 Changes for src/prints/themes.py: 60 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env python3 # Modules libraries try: from prompt_toolkit.styles.style import Style as prompt_toolkit_styles_Style except ModuleNotFoundError: # pragma: no cover from typing import Any as prompt_toolkit_styles_Style # type: ignore[assignment] # Components from .colors import Colors # Themes class, pylint: disable=too-few-public-methods class Themes: # Flags __prepared = False # Members __bold: str = '' __red: str = '' __selected: str = '' # Prepare @staticmethod def __prepare() -> None: # Colors enabled if Colors.enabled(): Themes.__bold = 'bold' Themes.__red = '#FF0000 bold' Themes.__selected = 'bold noreverse' # Colors disabled else: Themes.__bold = 'noinherit bold' Themes.__red = 'noinherit bold' Themes.__selected = 'noinherit bold noreverse' # Raise flag Themes.__prepared = True # Confirmation @staticmethod def confirmation_style() -> prompt_toolkit_styles_Style: # Prepare if not Themes.__prepared: Themes.__prepare() # Result return prompt_toolkit_styles_Style([ ('answer', Themes.__red), ('instruction', Themes.__red), ('highlighted', Themes.__bold), ('pointer', Themes.__bold), ('qmark', Themes.__bold), ('question', Themes.__bold), ('selected', Themes.__selected), ('separator', Themes.__bold), ]) Loading
src/cli/entrypoint.py +42 −2 Changes for src/cli/entrypoint.py: 42 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ from gitlab.v4.objects import ( Project as GitLabProject, User as GitLabUser, ) import questionary # Components from ..features.gitlab import GitLabFeature from ..prints.colors import Colors from ..prints.themes import Themes from ..system.platform import Platform from ..types.namespaces import Namespaces Loading Loading @@ -173,6 +175,30 @@ class Entrypoint: # Result return Entrypoint.Result.SUCCESS # Confirm @staticmethod def confirm(description: str, text: str = '') -> bool: # Header print( f'{Colors.BOLD} - Delete {description}: Confirm "' f'{Colors.RED}{text}' f'{Colors.BOLD}" deletion:' f'{Colors.RESET}', end='') Platform.flush() # Get user configuration answer: bool = questionary.confirm( message='', default=False, qmark='', style=Themes.confirmation_style(), auto_enter=True, ).ask() # Result return answer # Group @staticmethod def group( Loading Loading @@ -205,8 +231,15 @@ class Entrypoint: f'{Colors.RESET}') Platform.flush() # Delete group # Delete group after validation if options.delete_group: if not Entrypoint.confirm( group_type, group.full_path, ): return Entrypoint.Result.SUCCESS # Delete group gitlab.group_delete(criteria) print(f'{Colors.BOLD} - Delete {group_type}: ' f'{Colors.GREEN}Success' Loading Loading @@ -289,8 +322,15 @@ class Entrypoint: f'{Colors.RESET}') Platform.flush() # Delete project # Delete project after validation if options.delete_project: if not Entrypoint.confirm( 'project', project.path_with_namespace, ): return Entrypoint.Result.SUCCESS # Delete project gitlab.project_delete(criteria) print(f'{Colors.BOLD} - Delete project: ' f'{Colors.GREEN}Success' Loading
src/prints/themes.py 0 → 100644 +60 −0 Changes for src/prints/themes.py: 60 added lines, 0 removed lines. Original line number Diff line number Diff line #!/usr/bin/env python3 # Modules libraries try: from prompt_toolkit.styles.style import Style as prompt_toolkit_styles_Style except ModuleNotFoundError: # pragma: no cover from typing import Any as prompt_toolkit_styles_Style # type: ignore[assignment] # Components from .colors import Colors # Themes class, pylint: disable=too-few-public-methods class Themes: # Flags __prepared = False # Members __bold: str = '' __red: str = '' __selected: str = '' # Prepare @staticmethod def __prepare() -> None: # Colors enabled if Colors.enabled(): Themes.__bold = 'bold' Themes.__red = '#FF0000 bold' Themes.__selected = 'bold noreverse' # Colors disabled else: Themes.__bold = 'noinherit bold' Themes.__red = 'noinherit bold' Themes.__selected = 'noinherit bold noreverse' # Raise flag Themes.__prepared = True # Confirmation @staticmethod def confirmation_style() -> prompt_toolkit_styles_Style: # Prepare if not Themes.__prepared: Themes.__prepare() # Result return prompt_toolkit_styles_Style([ ('answer', Themes.__red), ('instruction', Themes.__red), ('highlighted', Themes.__bold), ('pointer', Themes.__bold), ('qmark', Themes.__bold), ('question', Themes.__bold), ('selected', Themes.__selected), ('separator', Themes.__bold), ])