diff --git a/swh/core/cli/db.py b/swh/core/cli/db.py --- a/swh/core/cli/db.py +++ b/swh/core/cli/db.py @@ -323,8 +323,14 @@ metavar="VERSION", default=None, ) +@click.option( + "--non-interactive", + is_flag=True, + help="Do not ask questions (use default answer to all questions)", + default=False, +) @click.pass_context -def db_upgrade(ctx, module, to_version): +def db_upgrade(ctx, module, to_version, non_interactive): """Upgrade the database for given module (to a given version if specified). Examples:: @@ -360,7 +366,7 @@ fg="yellow", bold=True, ) - if not click.confirm( + if not non_interactive and not click.confirm( f"Write the module information ({module}) in the database?", default=True ): raise click.BadParameter("Migration aborted.")