add config file and modules file cli options
allow to provide a config file and a modules file option to use different files than the default ones. this is useful when using the same environment for different databases.
This commit is contained in:
parent
93dc52ee5f
commit
148aa5f89f
|
|
@ -33,6 +33,9 @@ from odoo_openupgrade_wizard.cli.cli_run import run
|
|||
from odoo_openupgrade_wizard.cli.cli_upgrade import upgrade
|
||||
from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
|
||||
|
||||
DEFAULT_CONFIG_FILE = "config.yml"
|
||||
DEFAULT_MODULES_FILE = "modules.csv"
|
||||
|
||||
|
||||
@click.group()
|
||||
@click.version_option(version=odoo_openupgrade_wizard.__version__)
|
||||
|
|
@ -49,6 +52,29 @@ from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
|
|||
" and all the Odoo code required to make the migrations. Let empty to"
|
||||
" use current folder (./).",
|
||||
)
|
||||
@click.option(
|
||||
"-c",
|
||||
"--config-file",
|
||||
type=click.Path(
|
||||
exists=True,
|
||||
file_okay=True,
|
||||
),
|
||||
help=(
|
||||
f"Configuration file to use. By default, a file named "
|
||||
f'"{DEFAULT_CONFIG_FILE}" in the environment folder will be used.'
|
||||
),
|
||||
)
|
||||
@click.option(
|
||||
"--modules-file",
|
||||
type=click.Path(
|
||||
exists=True,
|
||||
file_okay=True,
|
||||
),
|
||||
help=(
|
||||
f"Modules file to use. By default, a file named "
|
||||
f'"{DEFAULT_MODULES_FILE}" in the environment folder will be used.'
|
||||
),
|
||||
)
|
||||
@click.option(
|
||||
"--filestore-folder",
|
||||
type=click.Path(
|
||||
|
|
@ -60,7 +86,9 @@ from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
|
|||
)
|
||||
@click.option("-l", "--log-level", type=LogLevel(), default=logging.INFO)
|
||||
@click.pass_context
|
||||
def main(ctx, env_folder, filestore_folder, log_level):
|
||||
def main(
|
||||
ctx, env_folder, config_file, modules_file, filestore_folder, log_level
|
||||
):
|
||||
"""
|
||||
Provides a command set to perform odoo Community Edition migrations.
|
||||
"""
|
||||
|
|
@ -92,8 +120,15 @@ def main(ctx, env_folder, filestore_folder, log_level):
|
|||
log_file_path = log_folder_path / Path(log_prefix + ".log")
|
||||
logger.add(log_file_path)
|
||||
|
||||
config_file_path = env_folder_path / Path("config.yml")
|
||||
module_file_path = env_folder_path / Path("modules.csv")
|
||||
if config_file:
|
||||
config_file_path = Path(config_file)
|
||||
else:
|
||||
config_file_path = env_folder_path / Path(DEFAULT_CONFIG_FILE)
|
||||
|
||||
if modules_file:
|
||||
module_file_path = Path(modules_file)
|
||||
else:
|
||||
module_file_path = env_folder_path / Path(DEFAULT_MODULES_FILE)
|
||||
|
||||
# Add all global values in the context
|
||||
ctx.obj["env_folder_path"] = env_folder_path
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user