Merge branch 'add-config-file-cli-option' into 'main'
add config file and modules file cli options See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!68
This commit is contained in:
commit
de0ea69f59
|
|
@ -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.cli.cli_upgrade import upgrade
|
||||||
from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
|
from odoo_openupgrade_wizard.tools.tools_system import ensure_folder_exists
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_FILE = "config.yml"
|
||||||
|
DEFAULT_MODULES_FILE = "modules.csv"
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.version_option(version=odoo_openupgrade_wizard.__version__)
|
@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"
|
" and all the Odoo code required to make the migrations. Let empty to"
|
||||||
" use current folder (./).",
|
" 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(
|
@click.option(
|
||||||
"--filestore-folder",
|
"--filestore-folder",
|
||||||
type=click.Path(
|
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.option("-l", "--log-level", type=LogLevel(), default=logging.INFO)
|
||||||
@click.pass_context
|
@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.
|
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")
|
log_file_path = log_folder_path / Path(log_prefix + ".log")
|
||||||
logger.add(log_file_path)
|
logger.add(log_file_path)
|
||||||
|
|
||||||
config_file_path = env_folder_path / Path("config.yml")
|
if config_file:
|
||||||
module_file_path = env_folder_path / Path("modules.csv")
|
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
|
# Add all global values in the context
|
||||||
ctx.obj["env_folder_path"] = env_folder_path
|
ctx.obj["env_folder_path"] = env_folder_path
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user