Commit 1bf9b99b authored by Adrian DC's avatar Adrian DC
Browse files

feat(cli): implement '--confirm' to bypass interactive user confirmations

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 35f51395
Loading
Loading
Loading
Loading
Loading
+3 −2
Changes for README.md: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ gitlab-projects-settings --reset-features 'https://gitlab.com/group/project'

```yaml
usage: gitlab-projects-settings [-h] [--version] [--update-check] [--settings] [--set GROUP KEY VAL] [-t TOKEN]
                                [--dry-run] [--dump] [--exclude-group] [--exclude-subgroups] [--exclude-projects]
                                [--available-features] [--reset-features [KEEP_FEATURES]]
                                [--confirm] [--dry-run] [--dump] [--exclude-group] [--exclude-subgroups]
                                [--exclude-projects] [--available-features] [--reset-features [KEEP_FEATURES]]
                                [--disable-features FEATURES] [--enable-features FEATURES] [--reset-members]
                                [--set-avatar FILE] [--set-description TEXT] [--update-description]
                                [--run-housekeeping] [--archive-project | --unarchive-project] [--delete-group]
@@ -73,6 +73,7 @@ credentials arguments:
  -t TOKEN                          # GitLab API token (default: GITLAB_TOKEN environment)

common settings arguments:
  --confirm                         # Automatically confirm all removal and contents warnings
  --dry-run                         # Enable dry run mode to check without saving
  --dump                            # Dump Python objects of groups and projects
  --exclude-group                   # Exclude parent group settings
+10 −0
Changes for src/cli/entrypoint.py: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ class Entrypoint:
    def confirm(
        description: str,
        text: str = '',
        interactive: bool = True,
        action: str = '',
    ) -> bool:

@@ -198,6 +199,13 @@ class Entrypoint:
            f'{Colors.RESET}', end='')
        Platform.flush()

        # Confirm without user interaction
        if not interactive:
            print(f'{Colors.RED} Confirmed by parameters'
                  f'{Colors.RESET}')
            Platform.flush()
            return True

        # Get user configuration
        answer: bool = questionary.confirm(
            message='',
@@ -247,6 +255,7 @@ class Entrypoint:
            if not Entrypoint.confirm(
                    f'Delete {group_type}',
                    group.full_path,
                    not options.confirm,
                    'deletion',
            ):
                print(' ')
@@ -346,6 +355,7 @@ class Entrypoint:
            if not Entrypoint.confirm(
                    'Delete project',
                    project.path_with_namespace,
                    not options.confirm,
                    'deletion',
            ):
                print(' ')
+6 −0
Changes for src/cli/main.py: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ def main() -> None:

    # Arguments common settings definitions
    group = parser.add_argument_group('common settings arguments')
    group.add_argument(
        '--confirm',
        dest='confirm',
        action='store_true',
        help='Automatically confirm all removal and contents warnings',
    )
    group.add_argument(
        '--dry-run',
        dest='dry_run',