feat: tiramisu_cache has to be defined in cli namespace

This commit is contained in:
egarette@silique.fr 2026-01-12 08:58:28 +01:00
parent 0c40462af0
commit a5bfc6aecb
3 changed files with 24 additions and 4 deletions

View file

@ -297,7 +297,7 @@ def get_output(rougailconfig, metaconfig, config, err_warn, layer_datas):
_('cannot find cli file for "output_name" module "{0}"').format(output_name)
)
module = load_modules("rougail.output_" + output_name, str(path))
root = self.rougailconfig["cli.root"]
root = rougailconfig["cli.root"]
if root:
subconfig = config.option(root)
else:

View file

@ -24,6 +24,12 @@ def get_rougail_config(
backward_compatibility: bool = True, # pylint: disable=unused-argument
) -> dict:
options = f"""
tiramisu_cache:
redefine: true
hidden: true
default:
variable: _.cli.tiramisu_cache
cli:
description: {_('Command line options')}
help: {_('It is possible to use Rougail directly from the command line. This makes it easy to define and configure the loaded user data and to define the desired output.')}
@ -61,6 +67,20 @@ cli:
default: true
hidden: true
tiramisu_cache:
description: {_("Store Tiramisu cache filename")}
help: |-
{_("This file contains the Tiramisu instructions used internally to load the variables.")}"
{_("This file can be used for load Tiramisu from cache instead of regenerates it")}"
alternative_name: ct
type: unix_filename
mandatory: false
params:
allow_relative: true
types:
- file
load_from_tiramisu_cache:
description: {_('Use cache for load Tiramisu objects')}
help: |-
@ -69,7 +89,7 @@ cli:
{_('Note that certain user data or output can change how structure files are loaded (this is particularly true for the doc output). It is best to use the cache only for the same type of user data and output.')}
default: false
disabled:
variable: __.tiramisu_cache
variable: _.tiramisu_cache
when: null
root:

View file

@ -134,10 +134,10 @@ def test_cli_tiramis_cache():
tmp_file.parent.mkdir(exist_ok=True)
tmp_file.unlink(missing_ok=True)
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'choice_rougailcli.yml'
main(['--tiramisu_cache', str(tmp_file), '--cli.load_from_tiramisu_cache'], do_not_print=True)
main(['--cli.tiramisu_cache', str(tmp_file), '--cli.load_from_tiramisu_cache'], do_not_print=True)
# we don't want to load .rougailcli.yml file
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = '.unknown.yml'
ret = main(['--main_structural_directories', 'structures_warnings', '--tiramisu_cache', str(tmp_file), '--cli.load_from_tiramisu_cache'], do_not_print=True)
ret = main(['--main_structural_directories', 'structures_warnings', '--cli.tiramisu_cache', str(tmp_file), '--cli.load_from_tiramisu_cache'], do_not_print=True)
filename = Path('choice_console.txt')
if not filename.is_file():
with filename.open('w') as fh: