cli: always require --database argument for commands that needs it
(run, psql, generate_module_analysis, install_from_csv), prevent it from being None resulting in funky stuff
This commit is contained in:
parent
79b499d6e0
commit
d59c487d1b
2
newsfragments/require-database-arg.fix
Normal file
2
newsfragments/require-database-arg.fix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Require to specify the --database arg for every command that needs it
|
||||
(install_from_csv, psql, run, generate_module_analysis)
|
||||
|
|
@ -2,7 +2,7 @@ import click
|
|||
from loguru import logger
|
||||
|
||||
from odoo_openupgrade_wizard.cli.cli_options import (
|
||||
database_option,
|
||||
database_option_required,
|
||||
get_migration_steps_from_options,
|
||||
step_option,
|
||||
)
|
||||
|
|
@ -23,7 +23,7 @@ from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_writable
|
|||
|
||||
@click.command()
|
||||
@step_option
|
||||
@database_option
|
||||
@database_option_required
|
||||
@click.option(
|
||||
"-m",
|
||||
"--modules",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import click
|
|||
from loguru import logger
|
||||
|
||||
from odoo_openupgrade_wizard.cli.cli_options import (
|
||||
database_option,
|
||||
database_option_required,
|
||||
demo_option,
|
||||
get_migration_step_from_options,
|
||||
)
|
||||
|
|
@ -16,7 +16,7 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
|
|||
|
||||
|
||||
@click.command()
|
||||
@database_option
|
||||
@database_option_required
|
||||
@demo_option
|
||||
@click.pass_context
|
||||
def install_from_csv(ctx, database, with_demo):
|
||||
|
|
|
|||
|
|
@ -53,16 +53,6 @@ def demo_option(function):
|
|||
return function
|
||||
|
||||
|
||||
def database_option(function):
|
||||
function = click.option(
|
||||
"-d",
|
||||
"--database",
|
||||
type=str,
|
||||
help="Odoo Database for which you want to perform the operation.",
|
||||
)(function)
|
||||
return function
|
||||
|
||||
|
||||
def database_option_required(function):
|
||||
function = click.option(
|
||||
"-d",
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import click
|
||||
|
||||
from odoo_openupgrade_wizard.cli.cli_options import database_option
|
||||
from odoo_openupgrade_wizard.cli.cli_options import database_option_required
|
||||
from odoo_openupgrade_wizard.tools.tools_postgres import execute_psql_command
|
||||
|
||||
|
||||
@click.command(context_settings={"ignore_unknown_options": True})
|
||||
@database_option
|
||||
@database_option_required
|
||||
@click.option("-c", "--command", "request")
|
||||
@click.option("--pager/--no-pager", default=True)
|
||||
@click.argument("psql_args", nargs=-1, type=click.UNPROCESSED)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import click
|
|||
from loguru import logger
|
||||
|
||||
from odoo_openupgrade_wizard.cli.cli_options import (
|
||||
database_option,
|
||||
database_option_required,
|
||||
demo_option,
|
||||
get_migration_step_from_options,
|
||||
step_option,
|
||||
|
|
@ -13,7 +13,7 @@ from odoo_openupgrade_wizard.tools.tools_postgres import ensure_database
|
|||
|
||||
@click.command()
|
||||
@step_option
|
||||
@database_option
|
||||
@database_option_required
|
||||
@demo_option
|
||||
@click.option(
|
||||
"--stop-after-init",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user