rougail-cli/src/rougail/cli/config.py

186 lines
6 KiB
Python

"""
Silique (https://www.silique.fr)
Copyright (C) 2025-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .i18n import _
def get_rougail_config(
*,
backward_compatibility: bool = True, # pylint: disable=unused-argument
) -> dict:
options = f"""
tiramisu_cache:
redefine: 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.')}
config_file:
description: {_('Loads command line parameters from a file')}
type: unix_filename
commandline: false
params:
allow_relative: true
default:
- .rougailcli.yml
debug: false # {_('Displays debug informations')}
warnings: true # {_('Displays command line option warnings informations')}
versions: false # {_('Displays Rougail version and all its components')}
invalid_user_data_error: false # {_("Invalid value in user data is not allowed")}
unknown_user_data_error: false # {_("Unknown variable in user data is not allowed")}
layers:
description: {_('Open each user data in separate layers')}
alternative_name: cl
default: false
hidden:
jinja: |-
{{{{ __.step.user_data is propertyerror or __.step.user_data | length < 2 }}}}
return_type: boolean
description: {_('if only one user data is set in "__.step.user_data"')}
load_config:
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: |-
{_('It will only be loaded from the cache if it already exists')}
{_('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
when: null
root:
description: {_('Use output only for the children variables of the family')}
help: {_('By default, all accessible variables are included in output. It is possible to define the family from which the output should be generated.')}
alternative_name: cr
mandatory: false
read_write: false # {_('Configuration in output step is in read_write mode')}
mandatory:
description: {_('test mandatories variables')}
help: |-
{_("The configuration must be valid before process output. It's better to validate the values at the beginning of the process.")}
type: boolean
default:
jinja: |-
{{{{ cli.read_write == false }}}}
description: {_('if "cli.read_write" is false')}
description_type:
description: {_('Type of variables description')}
alternative_name: cd
help: >-
{_("""To identify different variables, we use the variable description. There are four types of description:
- path_and_description: which contains the variable path followed by its description
- name_and_description: which contains the variable name followed by its description
- path: the variable's path
- name: the variable name
- description: the variable's description""")}
choices:
- path_and_description
- name_and_description
- path
- name
- description
default: description
inaccessible_read_only_modes:
description: {_('Modes that should not be accessible in read_only mode')}
multi: true
mandatory: false
disabled:
jinja: |
{{{{ not modes_level }}}}
return_type: boolean
description: {_('if any mode is set in "modes_level"')}
validators:
- type: jinja
jinja: |
{{% if _.inaccessible_read_only_modes not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
description: {_('mode must exists in "modes_level"')}
inaccessible_read_write_modes:
description: {_('Modes that should not be accessible in read_write mode')}
multi: true
mandatory: false
disabled:
jinja: |
{{{{ not modes_level }}}}
return_type: boolean
description: {_('if any mode is set in "modes_level"')}
validators:
- type: jinja
jinja: |
{{% if _.inaccessible_read_write_modes not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
description: {_('mode must exists in "modes_level"')}
inaccessible_modes:
description: {_('Modes that should not be accessible')}
alternative_name: ci
multi: true
mandatory: false
disabled:
jinja: |
{{{{ not modes_level }}}}
return_type: boolean
description: {_('if any mode is set in "modes_level"')}
validators:
- type: jinja
jinja: |
{{% if _.inaccessible_modes not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
description: {_('mode must exists in "modes_level"')}
"""
return {
"options": options,
"process": None,
}