Compare commits

...

3 commits

8 changed files with 59 additions and 6 deletions

View file

@ -1,3 +1,13 @@
## 0.2.0a41 (2026-01-12)
### Feat
- tiramisu_cache has to be defined in cli namespace
### Fix
- add test with rougailcli that assign a symlinkoption
## 0.2.0a40 (2026-01-04)
### Feat

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.cli"
version = "0.2.0a40"
version = "0.2.0a41"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "CLI for Rougail"

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

@ -1 +1 @@
__version__ = "0.2.0a40"
__version__ = "0.2.0a41"

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

@ -0,0 +1 @@
["unable to load \"Main namespace name\", is a symlink option so we cannot set the value \"doc\", it will be ignored when loading from the YAML file \"symlink_rougailcli.yml\""]

View file

@ -0,0 +1,4 @@
---
main_structural_directories:
- structures
s: doc

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:
@ -289,3 +289,21 @@ def test_cli_rougailcli_choice():
data = loads(fh.read())
assert ret == (True, data), str(filename.absolute())
os.environ = save
def test_cli_rougailcli_symlink():
save = os.environ.copy()
with chdir(test_dir / 'rougailcli_file'):
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'symlink_rougailcli.yml'
with warnings.catch_warnings(record=True) as rougail_wn:
warnings.simplefilter("always", UserWarning)
main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
ret = [str(w.message) for w in rougail_wn]
filename = Path('symlink_rougailcli.txt')
if not filename.is_file():
with filename.open('w') as fh:
fh.write(dumps([str(w.message) for w in rougail_wn]))
with filename.open() as fh:
data = loads(fh.read())
assert ret == data, str(filename.absolute())
os.environ = save