diff --git a/oca_port/app.py b/oca_port/app.py index bd08f1d..a481ccf 100644 --- a/oca_port/app.py +++ b/oca_port/app.py @@ -46,6 +46,8 @@ class App(Output): flag to not wait for user input and to return a error code to the shell. Returns 100 if an addon could be migrated, 110 if pull requests/commits could be ported, 0 if the history of the addon is the same on both branches. + assume_yes: + Assume yes to prompts output: returns a parsable output. This implies the 'non-interactive' mode defined above but without returning any special exit code. @@ -73,6 +75,7 @@ class App(Output): upstream_org: str = "OCA" verbose: bool = False non_interactive: bool = False + assume_yes: bool = False dry_run: bool = False output: str = None fetch: bool = False diff --git a/oca_port/cli/main.py b/oca_port/cli/main.py index 91e8b01..ea04662 100644 --- a/oca_port/cli/main.py +++ b/oca_port/cli/main.py @@ -98,6 +98,7 @@ @click.option( "--non-interactive", is_flag=True, help="Disable all interactive prompts." ) +@click.option("-y", "--yes", "assume_yes", is_flag=True, help="Assume yes to prompts.") @click.option("--dry-run", is_flag=True, help="Print results, no nothing.") @click.option( "--output", @@ -128,6 +129,7 @@ def main( upstream_org: str, verbose: bool, non_interactive: bool, + assume_yes: bool, output: str, fetch: bool, no_cache: bool, @@ -163,6 +165,7 @@ def main( upstream_org=upstream_org, verbose=verbose, non_interactive=non_interactive, + assume_yes=assume_yes, output=output, fetch=fetch, no_cache=no_cache, diff --git a/oca_port/migrate_addon.py b/oca_port/migrate_addon.py index d50cf0f..4359b6b 100644 --- a/oca_port/migrate_addon.py +++ b/oca_port/migrate_addon.py @@ -96,7 +96,7 @@ def run(self): return False, None # At this stage, the addon could be migrated self._detect_existing_pr() - if self.app.non_interactive or self.app.dry_run: + if (self.app.non_interactive and not self.app.assume_yes) or self.app.dry_run: msg = ( f"ℹ️ {bc.BOLD}{self.app.source.addon}{bc.END} can be migrated " f"from {bc.BOLD}{self.app.source_version}{bc.END} " @@ -137,7 +137,7 @@ def run(self): confirm += f" and move it to {bc.BOLD}{self.app.target.addon_path}{bc.END}?" else: confirm += "?" - if not click.confirm(confirm): + if not (self.app.assume_yes or click.confirm(confirm)): self.app.storage.blacklist_addon(confirm=True) if not self.app.storage.dirty: return False, None @@ -262,7 +262,7 @@ def _create_mig_branch(self): f"Branch {bc.BOLD}{self.mig_branch.name}{bc.END} already exists, " "recreate it?\n(⚠️ you will lose the existing branch)" ) - if click.confirm(confirm): + if self.app.assume_yes or click.confirm(confirm): self.app.repo.delete_head(self.mig_branch.name, "-f") else: create_branch = False