Compare commits
96 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c3b6c9e98c | |||
| f53e8c19bc | |||
| a5bfc6aecb | |||
| 0c40462af0 | |||
| 09f2e51c3c | |||
| 72031b9880 | |||
| aa8110386a | |||
| 9b202495f8 | |||
| d156d7afc5 | |||
| 963e82b434 | |||
| 50c83aa3f4 | |||
| 5aae19de63 | |||
| 6830bbcc12 | |||
| 9ff04d53fb | |||
| cd9686011c | |||
| 7d8bfa87fd | |||
| 3ad2b9a587 | |||
| 585313e4bc | |||
| 1f537963df | |||
| 636cd59e7a | |||
| 0500688079 | |||
| 5ce01380bf | |||
| 004e314c3f | |||
| 8aacb91433 | |||
| e56815f684 | |||
| 82df953c70 | |||
| 5548144d2d | |||
| 67876d77a4 | |||
| ca636fe7a6 | |||
| ff58fc056a | |||
| ba82f91cc6 | |||
| ba0b326b56 | |||
| fe96019173 | |||
| 1af9610734 | |||
| 6d3759f3e4 | |||
| b7dbaaa95d | |||
| de98071a53 | |||
| d5c229ec50 | |||
| 83b20dc0c1 | |||
| 97c87c24d3 | |||
| d9c197ca72 | |||
| e0a45ad4a6 | |||
| 52069f00c3 | |||
| 358de23cb4 | |||
| 6946532f8d | |||
| 8c8d16b1dd | |||
| 01aa36c1d7 | |||
| dd08fb6e46 | |||
| 27ee7f0f1b | |||
| 2e7ba5695f | |||
| e4e0cc987d | |||
| 1c34145daf | |||
| 346401912c | |||
| 1576f105e0 | |||
| 82e9e5bc30 | |||
| 2bc7e3914c | |||
| c874fa8573 | |||
| da6a816713 | |||
| 57df91ebee | |||
| 8751165a7c | |||
| 63b2131908 | |||
| 577f354e70 | |||
| 10d495c9a8 | |||
| e11885fbd7 | |||
| 9fb4cb8351 | |||
| 0102eede49 | |||
| 05fcb14364 | |||
| aa5c2f773c | |||
| f5f85ba79f | |||
| cf0fc37aef | |||
| 8ecc0e0f55 | |||
| 0f1e1b9ea5 | |||
| 1036ccb358 | |||
| 5327ff1917 | |||
| c31652256f | |||
| 8c924a7cba | |||
| 3f2920f37c | |||
| 0010c9cf07 | |||
| fb7c3c3346 | |||
| e6582d6d9d | |||
| 5cfa351e67 | |||
| e9b1ab5f85 | |||
| 95da29454a | |||
| a530ff33d6 | |||
| dcbe1a99d6 | |||
| c0d103f2e8 | |||
| e87bcbd4c8 | |||
| 703b1ce70e | |||
| 60ee2a6feb | |||
| 6feebea664 | |||
| b5c845f90c | |||
| c79975c5df | |||
| 52cbfc1f15 | |||
| e62797c79f | |||
| 8073ef9bc1 | |||
| ea0076279c |
49 changed files with 1607 additions and 67 deletions
280
CHANGELOG.md
280
CHANGELOG.md
|
|
@ -1,3 +1,283 @@
|
|||
## 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
|
||||
|
||||
- add cli.root option to limit output from a specified family
|
||||
|
||||
## 0.2.0a39 (2026-01-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- load tiramisu objects from cache
|
||||
|
||||
## 0.2.0a38 (2026-01-01)
|
||||
|
||||
### Fix
|
||||
|
||||
- more than two layers
|
||||
|
||||
## 0.2.0a37 (2025-12-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- update doc
|
||||
- update tests
|
||||
|
||||
## 0.2.0a36 (2025-12-22)
|
||||
|
||||
### Fix
|
||||
|
||||
- add permissive properties for unaccessible modes
|
||||
|
||||
## 0.2.0a35 (2025-12-22)
|
||||
|
||||
### Fix
|
||||
|
||||
- documentation
|
||||
|
||||
## 0.2.0a34 (2025-12-22)
|
||||
|
||||
### Feat
|
||||
|
||||
- multi rougailcli.yml files
|
||||
|
||||
### Fix
|
||||
|
||||
- user_datas => user_data
|
||||
|
||||
## 0.2.0a33 (2025-11-21)
|
||||
|
||||
### Feat
|
||||
|
||||
- add inaccessible_read_write_modes and inaccessible_modes options
|
||||
|
||||
## 0.2.0a32 (2025-11-08)
|
||||
|
||||
### Fix
|
||||
|
||||
- execute interactive mode too
|
||||
|
||||
## 0.2.0a31 (2025-11-07)
|
||||
|
||||
### Fix
|
||||
|
||||
- better layers support
|
||||
|
||||
## 0.2.0a30 (2025-11-07)
|
||||
|
||||
### Feat
|
||||
|
||||
- layers information is send to output
|
||||
|
||||
## 0.2.0a29 (2025-11-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- choice if invalid value or unknown variable in user data is a fatal error or not
|
||||
|
||||
## 0.2.0a28 (2025-11-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- support layers
|
||||
|
||||
### Fix
|
||||
|
||||
- do not display full help to early
|
||||
|
||||
## 0.2.0a27 (2025-10-31)
|
||||
|
||||
### Fix
|
||||
|
||||
- remove all warnings!
|
||||
- update tests with new output_doc module
|
||||
|
||||
## 0.2.0a26 (2025-10-29)
|
||||
|
||||
### Fix
|
||||
|
||||
- add default option for environment user datas
|
||||
|
||||
## 0.2.0a25 (2025-10-27)
|
||||
|
||||
### Feat
|
||||
|
||||
- can use .rougailcli.yml, env variable or command line argument from own script
|
||||
|
||||
## 0.2.0a24 (2025-10-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- use rougail-user-data-commandline and mix config use data
|
||||
|
||||
### Fix
|
||||
|
||||
- remove force_apply_user_data support
|
||||
|
||||
## 0.2.0a23 (2025-10-03)
|
||||
|
||||
### Fix
|
||||
|
||||
- config in read_only mode is asked
|
||||
|
||||
## 0.2.0a22 (2025-10-02)
|
||||
|
||||
### Feat
|
||||
|
||||
- limit warning when asked
|
||||
|
||||
## 0.2.0a21 (2025-09-29)
|
||||
|
||||
### Feat
|
||||
|
||||
- add cli.read_write option
|
||||
|
||||
## 0.2.0a20 (2025-09-22)
|
||||
|
||||
### Fix
|
||||
|
||||
- dictionary => structure
|
||||
|
||||
## 0.2.0a19 (2025-09-03)
|
||||
|
||||
### Fix
|
||||
|
||||
- do now set modified option in second round
|
||||
|
||||
## 0.2.0a18 (2025-05-14)
|
||||
|
||||
### Feat
|
||||
|
||||
- able to lad config_file name from environement variable
|
||||
- loads user datas before and after cli params
|
||||
|
||||
## 0.2.0a17 (2025-05-12)
|
||||
|
||||
### Fix
|
||||
|
||||
- upgrade translation
|
||||
- black
|
||||
|
||||
## 0.2.0a16 (2025-05-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- description
|
||||
|
||||
## 0.2.0a15 (2025-05-05)
|
||||
|
||||
### Fix
|
||||
|
||||
- do not raise if warning in cli
|
||||
|
||||
## 0.2.0a14 (2025-05-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- do not force use_data usage
|
||||
|
||||
## 0.2.0a13 (2025-04-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- add first test + remove add_extra_options option in tiramisu-cmdline-parser
|
||||
- remove negative_description support
|
||||
- display user-data instead of user_data in version
|
||||
|
||||
## 0.2.0a12 (2025-04-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- version
|
||||
|
||||
## 0.2.0a11 (2025-03-31)
|
||||
|
||||
### Fix
|
||||
|
||||
- translation
|
||||
|
||||
## 0.2.0a10 (2025-03-31)
|
||||
|
||||
### Fix
|
||||
|
||||
- access to cli.config_file variable with commandline
|
||||
|
||||
## 0.2.0a9 (2025-03-31)
|
||||
|
||||
### Feat
|
||||
|
||||
- cli loads .rougailcli.yml file
|
||||
|
||||
## 0.2.0a8 (2025-02-17)
|
||||
|
||||
### Fix
|
||||
|
||||
- add config.py file
|
||||
|
||||
## 0.2.0a7 (2025-02-17)
|
||||
|
||||
### Fix
|
||||
|
||||
- better error support
|
||||
|
||||
## 0.2.0a6 (2025-02-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- return 1 if output has problems
|
||||
|
||||
## 0.2.0a5 (2025-02-05)
|
||||
|
||||
### Feat
|
||||
|
||||
- user_data can be loaded after other plugins
|
||||
|
||||
## 0.2.0a4 (2025-01-04)
|
||||
|
||||
### Fix
|
||||
|
||||
- add and remove not_for_commandline property
|
||||
|
||||
## 0.2.0a3 (2025-01-04)
|
||||
|
||||
### Fix
|
||||
|
||||
- remove upgrade feature (now in formatter project) + better support of not_for_commandline feature
|
||||
|
||||
## 0.2.0a2 (2024-12-11)
|
||||
|
||||
### Fix
|
||||
|
||||
- user_data and output are not plugins
|
||||
|
||||
## 0.2.0a1 (2024-11-28)
|
||||
|
||||
### Fix
|
||||
|
||||
- separation between run and print function
|
||||
|
||||
## 0.2.0a0 (2024-11-27)
|
||||
|
||||
### Feat
|
||||
|
||||
- load config from environment if rougail-user-data-environment is installed
|
||||
|
||||
### Fix
|
||||
|
||||
- translation is not mandatory
|
||||
|
||||
## 0.1.1 (2024-11-06)
|
||||
|
||||
## 0.1.1rc0 (2024-11-06)
|
||||
|
||||
### Fix
|
||||
|
|
|
|||
31
README.fr.md
Normal file
31
README.fr.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
|
||||
|
||||
## Options de la ligne de commande
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> Il est possible d'utiliser Rougail directement en ligne de commande. Il est possible de définir et configurer facilement les données utilisateur chargées, ainsi que la définition de la sortie souhaité.\
|
||||
> **Chemin** : cli
|
||||
|
||||
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|
||||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **<a id="cli.config_file" name="cli.config_file">cli.config_file</a>**<br/>**Variable d'environnement** : CLI.CONFIG_FILE | Charger les paramètres de la ligne de commande depuis un fichier. | • .rougailcli.yml | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | | • le nom de fichier peut être une chemin relatif<br/>• type de fichier autorisé: "fichier" et "répertoire". |
|
||||
| **<a id="cli.debug" name="cli.debug">cli.debug</a>**<br/>**Ligne de commande** : <br/>• --cli.debug<br/>• --cli.no-debug<br/>**Variable d'environnement** : CLI.DEBUG | Afficher les informations de debug. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.warnings" name="cli.warnings">cli.warnings</a>**<br/>**Ligne de commande** : <br/>• --cli.warnings<br/>• --cli.no-warnings<br/>**Variable d'environnement** : CLI.WARNINGS | Afficher les avertissements de chargement des options de la ligne de commande. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.versions" name="cli.versions">cli.versions</a>**<br/>**Ligne de commande** : <br/>• --cli.versions<br/>• --cli.no-versions<br/>**Variable d'environnement** : CLI.VERSIONS | Afficher la version de Rougail et de tous ces composants. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.invalid_user_data_error" name="cli.invalid_user_data_error">cli.invalid_user_data_error</a>**<br/>**Ligne de commande** : <br/>• --cli.invalid_user_data_error<br/>• --cli.no-invalid_user_data_error<br/>**Variable d'environnement** : CLI.INVALID_USER_DATA_ERROR | Les valeurs invalides dans les données utilisateur ne sont pas autorisées. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.unknown_user_data_error" name="cli.unknown_user_data_error">cli.unknown_user_data_error</a>**<br/>**Ligne de commande** : <br/>• --cli.unknown_user_data_error<br/>• --cli.no-unknown_user_data_error<br/>**Variable d'environnement** : CLI.UNKNOWN_USER_DATA_ERROR | Les variables inconnues dans les données utilisateur ne sont pas autorisées. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.layers" name="cli.layers">cli.layers</a>**<br/>**Ligne de commande** : <br/>• -cl, --cli.layers<br/>• -ncl, --cli.no-layers<br/>**Variable d'environnement** : CLI.LAYERS | Charger chaque données utilisateurs dans des couches séparées. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | *`cachée`*<br/>**Cachée** : si seulement un type de données utilisateur est renseigné dans "[Sélection pour données utilisateur](#step.user_data)" | |
|
||||
| **<a id="cli.load_from_tiramisu_cache" name="cli.load_from_tiramisu_cache">cli.load_from_tiramisu_cache</a>**<br/>**Ligne de commande** : <br/>• --cli.load_from_tiramisu_cache<br/>• --cli.no-load_from_tiramisu_cache<br/>**Variable d'environnement** : CLI.LOAD_FROM_TIRAMISU_CACHE | Utiliser le cache pour charger les objets Tiramisu.<br/>Il sera chargé à partir du cache uniquement si celui-ci existe déjà.<br/><br/>Attention, certain données utilisateur ou sortie peuvent changer la manière dont sont chargés les fichiers de structure (c'est notamment le cas avec la sortie doc). Il est préférable de n'utiliser le cache pour le même type de données utilisateur et sortie. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | *`désactivé`*<br/>**Désactivé** : lorsque la variable "[Enregistrer le cache Tiramisu dans le fichier](#tiramisu_cache)" a la valeur "null" | |
|
||||
| **<a id="cli.root" name="cli.root">cli.root</a>**<br/>**Ligne de commande** : <br/>-cr, --cli.root<br/>**Variable d'environnement** : CLI.ROOT | Utiliser la sortie uniquement pour les variables enfants de la famille.<br/>Par défaut, toutes les variables accessible sont inclus dans la sortie. Il est possible de définir la famille a partir de laquelle la sortie devra être générée. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | | |
|
||||
| **<a id="cli.read_write" name="cli.read_write">cli.read_write</a>**<br/>**Ligne de commande** : <br/>• --cli.read_write<br/>• --cli.no-read_write<br/>**Variable d'environnement** : CLI.READ_WRITE | La configuration dans l'état de sortie est dans mode lecture-écriture. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | |
|
||||
| **<a id="cli.description_type" name="cli.description_type">cli.description_type</a>**<br/>**Ligne de commande** : <br/>-cd, --cli.description_type<br/>**Variable d'environnement** : CLI.DESCRIPTION_TYPE | Type de description des variables.<br/>Pour identifier les différentes variables, on utilise la description de la variable. Il y a quatre type de descriptions:<br/>- name_and_description : qui contient le nom de la variable suivi de sa description - path : le chemin de la variable - name : le nom de la variable - description : la description de la variable. | description | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | | **Choix** : <br/>• path_and_description<br/>• name_and_description<br/>• path<br/>• name<br/>• description |
|
||||
| **<a id="cli.inaccessible_read_only_modes" name="cli.inaccessible_read_only_modes">cli.inaccessible_read_only_modes</a>**<br/>**Ligne de commande** : <br/>--cli.inaccessible_read_only_modes<br/>**Variable d'environnement** : CLI.INACCESSIBLE_READ_ONLY_MODES | Modes quoi doivent être inaccessible en mode lecture seule. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`désactivé`*<br/>**Désactivé** : si aucun mode n'est défini dans "[Tous les niveaux de modes valides](#modes_level)" | `unique`<br/>Un mode doit exister dans "[Tous les niveaux de modes valides](#modes_level)". |
|
||||
| **<a id="cli.inaccessible_read_write_modes" name="cli.inaccessible_read_write_modes">cli.inaccessible_read_write_modes</a>**<br/>**Ligne de commande** : <br/>--cli.inaccessible_read_write_modes<br/>**Variable d'environnement** : CLI.INACCESSIBLE_READ_WRITE_MODES | Modes quoi doivent être inaccessible en mode lecture-écriture. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`désactivé`*<br/>**Désactivé** : si aucun mode n'est défini dans "[Tous les niveaux de modes valides](#modes_level)" | `unique`<br/>Un mode doit exister dans "[Tous les niveaux de modes valides](#modes_level)". |
|
||||
| **<a id="cli.inaccessible_modes" name="cli.inaccessible_modes">cli.inaccessible_modes</a>**<br/>**Ligne de commande** : <br/>-ci, --cli.inaccessible_modes<br/>**Variable d'environnement** : CLI.INACCESSIBLE_MODES | Modes quoi doivent être inaccessible. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`désactivé`*<br/>**Désactivé** : si aucun mode n'est défini dans "[Tous les niveaux de modes valides](#modes_level)" | `unique`<br/>Un mode doit exister dans "[Tous les niveaux de modes valides](#modes_level)". |
|
||||
|
||||
|
||||
31
README.md
31
README.md
|
|
@ -1,2 +1,31 @@
|
|||
# rougail-cli
|
||||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
|
||||
|
||||
## Command line options
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> 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.\
|
||||
> **Path**: cli
|
||||
|
||||
| Variable | Description | Default value | Type | Access control | Validator |
|
||||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **<a id="cli.config_file" name="cli.config_file">cli.config_file</a>**<br/>**Environment variable**: CLI.CONFIG_FILE | Loads command line parameters from a file. | • .rougailcli.yml | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | | • this filename could be a relative path<br/>• file type allowed: "directory" and "file". |
|
||||
| **<a id="cli.debug" name="cli.debug">cli.debug</a>**<br/>**Command line**: <br/>• --cli.debug<br/>• --cli.no-debug<br/>**Environment variable**: CLI.DEBUG | Displays debug informations. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.warnings" name="cli.warnings">cli.warnings</a>**<br/>**Command line**: <br/>• --cli.warnings<br/>• --cli.no-warnings<br/>**Environment variable**: CLI.WARNINGS | Displays command line option warnings informations. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.versions" name="cli.versions">cli.versions</a>**<br/>**Command line**: <br/>• --cli.versions<br/>• --cli.no-versions<br/>**Environment variable**: CLI.VERSIONS | Displays Rougail version and all its components. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.invalid_user_data_error" name="cli.invalid_user_data_error">cli.invalid_user_data_error</a>**<br/>**Command line**: <br/>• --cli.invalid_user_data_error<br/>• --cli.no-invalid_user_data_error<br/>**Environment variable**: CLI.INVALID_USER_DATA_ERROR | Invalid value in user data is not allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.unknown_user_data_error" name="cli.unknown_user_data_error">cli.unknown_user_data_error</a>**<br/>**Command line**: <br/>• --cli.unknown_user_data_error<br/>• --cli.no-unknown_user_data_error<br/>**Environment variable**: CLI.UNKNOWN_USER_DATA_ERROR | Unknown variable in user data is not allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.layers" name="cli.layers">cli.layers</a>**<br/>**Command line**: <br/>• -cl, --cli.layers<br/>• -ncl, --cli.no-layers<br/>**Environment variable**: CLI.LAYERS | Open each user data in separate layers. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | *`hidden`*<br/>**Hidden**: if only one user data is set in "[Select for user datas](#step.user_data)" | |
|
||||
| **<a id="cli.load_from_tiramisu_cache" name="cli.load_from_tiramisu_cache">cli.load_from_tiramisu_cache</a>**<br/>**Command line**: <br/>• --cli.load_from_tiramisu_cache<br/>• --cli.no-load_from_tiramisu_cache<br/>**Environment variable**: CLI.LOAD_FROM_TIRAMISU_CACHE | Use cache for load Tiramisu objects.<br/>It will only be loaded from the cache if it already exists<br/><br/>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. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | *`disabled`*<br/>**Disabled**: when the variable "[Store Tiramisu cache filename](#tiramisu_cache)" has the value "null" | |
|
||||
| **<a id="cli.root" name="cli.root">cli.root</a>**<br/>**Command line**: <br/>-cr, --cli.root<br/>**Environment variable**: CLI.ROOT | Use output only for the children variables of the family.<br/>By default, all accessible variables are included in output. It is possible to define the family from which the output should be generated. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | | |
|
||||
| **<a id="cli.read_write" name="cli.read_write">cli.read_write</a>**<br/>**Command line**: <br/>• --cli.read_write<br/>• --cli.no-read_write<br/>**Environment variable**: CLI.READ_WRITE | Configuration in output step is in read_write mode. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | |
|
||||
| **<a id="cli.description_type" name="cli.description_type">cli.description_type</a>**<br/>**Command line**: <br/>-cd, --cli.description_type<br/>**Environment variable**: CLI.DESCRIPTION_TYPE | Type of variables description.<br/>To identify different variables, we use the variable description. There are four types of description:<br/>- 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. | description | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | | **Choices**: <br/>• path_and_description<br/>• name_and_description<br/>• path<br/>• name<br/>• description |
|
||||
| **<a id="cli.inaccessible_read_only_modes" name="cli.inaccessible_read_only_modes">cli.inaccessible_read_only_modes</a>**<br/>**Command line**: <br/>--cli.inaccessible_read_only_modes<br/>**Environment variable**: CLI.INACCESSIBLE_READ_ONLY_MODES | Modes that should not be accessible in read_only mode. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`disabled`*<br/>**Disabled**: if any mode is set in "[All modes level available](#modes_level)" | `unique`<br/>Mode must exists in "[All modes level available](#modes_level)". |
|
||||
| **<a id="cli.inaccessible_read_write_modes" name="cli.inaccessible_read_write_modes">cli.inaccessible_read_write_modes</a>**<br/>**Command line**: <br/>--cli.inaccessible_read_write_modes<br/>**Environment variable**: CLI.INACCESSIBLE_READ_WRITE_MODES | Modes that should not be accessible in read_write mode. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`disabled`*<br/>**Disabled**: if any mode is set in "[All modes level available](#modes_level)" | `unique`<br/>Mode must exists in "[All modes level available](#modes_level)". |
|
||||
| **<a id="cli.inaccessible_modes" name="cli.inaccessible_modes">cli.inaccessible_modes</a>**<br/>**Command line**: <br/>-ci, --cli.inaccessible_modes<br/>**Environment variable**: CLI.INACCESSIBLE_MODES | Modes that should not be accessible. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | *`disabled`*<br/>**Disabled**: if any mode is set in "[All modes level available](#modes_level)" | `unique`<br/>Mode must exists in "[All modes level available](#modes_level)". |
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,8 +5,8 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2024-10-31 09:57+0100\n"
|
||||
"PO-Revision-Date: 2024-10-31 10:00+0100\n"
|
||||
"POT-Creation-Date: 2026-01-04 19:05+0100\n"
|
||||
"PO-Revision-Date: 2026-01-04 19:07+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\n"
|
||||
|
|
@ -14,16 +14,165 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: pygettext.py 1.5\n"
|
||||
"X-Generator: Poedit 3.5\n"
|
||||
"X-Generator: Poedit 3.8\n"
|
||||
|
||||
#: src/rougail/cli/__main__.py:43
|
||||
#: src/rougail/cli/__main__.py:253
|
||||
msgid "cannot find \"user_data\" module \"{0}\""
|
||||
msgstr "ne peut trouve le module \"user_data\" \"{0}\""
|
||||
|
||||
#: src/rougail/cli/__main__.py:56
|
||||
#: src/rougail/cli/__main__.py:261
|
||||
msgid ""
|
||||
"interactive user data \"{0}\" is loader before uninteractive user data "
|
||||
"\"{1}\""
|
||||
msgstr ""
|
||||
"les données utilisateur interactifs \"{0}\" sont chargées avant les données "
|
||||
"utilisateur non interactif \"{1}\""
|
||||
|
||||
#: src/rougail/cli/__main__.py:297
|
||||
msgid "cannot find cli file for \"output_name\" module \"{0}\""
|
||||
msgstr "ne peut trouve le fichier cli pour le module \"output_name\" \"{0}\""
|
||||
|
||||
#: src/rougail/cli/__main__.py:69
|
||||
#: src/rougail/cli/__main__.py:328
|
||||
msgid "ERROR: {0}"
|
||||
msgstr "ERREUR : {0}"
|
||||
|
||||
#: src/rougail/cli/config.py:28
|
||||
msgid "Command line options"
|
||||
msgstr "Options de la ligne de commande"
|
||||
|
||||
#: src/rougail/cli/config.py:29
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Il est possible d'utiliser Rougail directement en ligne de commande. Il est "
|
||||
"possible de définir et configurer facilement les données utilisateur "
|
||||
"chargées, ainsi que la définition de la sortie souhaité."
|
||||
|
||||
#: src/rougail/cli/config.py:32
|
||||
msgid "Loads command line parameters from a file"
|
||||
msgstr "Charger les paramètres de la ligne de commande depuis un fichier"
|
||||
|
||||
#: src/rougail/cli/config.py:40
|
||||
msgid "Displays debug informations"
|
||||
msgstr "Afficher les informations de debug"
|
||||
|
||||
#: src/rougail/cli/config.py:42
|
||||
msgid "Displays command line option warnings informations"
|
||||
msgstr ""
|
||||
"Afficher les avertissements de chargement des options de la ligne de commande"
|
||||
|
||||
#: src/rougail/cli/config.py:44
|
||||
msgid "Displays Rougail version and all its components"
|
||||
msgstr "Afficher la version de Rougail et de tous ces composants"
|
||||
|
||||
#: src/rougail/cli/config.py:46
|
||||
msgid "Invalid value in user data is not allowed"
|
||||
msgstr ""
|
||||
"Les valeurs invalides dans les données utilisateur ne sont pas autorisées"
|
||||
|
||||
#: src/rougail/cli/config.py:48
|
||||
msgid "Unknown variable in user data is not allowed"
|
||||
msgstr ""
|
||||
"Les variables inconnues dans les données utilisateur ne sont pas autorisées"
|
||||
|
||||
#: src/rougail/cli/config.py:51
|
||||
msgid "Open each user data in separate layers"
|
||||
msgstr "Charger chaque données utilisateurs dans des couches séparées"
|
||||
|
||||
#: src/rougail/cli/config.py:58
|
||||
msgid "if only one user data is set in \"__.step.user_data\""
|
||||
msgstr ""
|
||||
"si seulement un type de données utilisateur est renseigné dans "
|
||||
"\"__.step.user_data\""
|
||||
|
||||
#: src/rougail/cli/config.py:65
|
||||
msgid "Use cache for load Tiramisu objects"
|
||||
msgstr "Utiliser le cache pour charger les objets Tiramisu"
|
||||
|
||||
#: src/rougail/cli/config.py:67
|
||||
msgid "It will only be loaded from the cache if it already exists"
|
||||
msgstr "Il sera chargé à partir du cache uniquement si celui-ci existe déjà."
|
||||
|
||||
#: src/rougail/cli/config.py:69
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
"Attention, certain données utilisateur ou sortie peuvent changer la manière "
|
||||
"dont sont chargés les fichiers de structure (c'est notamment le cas avec la "
|
||||
"sortie doc). Il est préférable de n'utiliser le cache pour le même type de "
|
||||
"données utilisateur et sortie."
|
||||
|
||||
#: src/rougail/cli/config.py:76
|
||||
msgid "Use output only for the children variables of the family"
|
||||
msgstr "Utiliser la sortie uniquement pour les variables enfants de la famille"
|
||||
|
||||
#: src/rougail/cli/config.py:77
|
||||
msgid ""
|
||||
"By default, all accessible variables are included in output. It is possible "
|
||||
"to define the family from which the output should be generated."
|
||||
msgstr ""
|
||||
"Par défaut, toutes les variables accessible sont inclus dans la sortie. Il "
|
||||
"est possible de définir la famille a partir de laquelle la sortie devra être "
|
||||
"générée."
|
||||
|
||||
#: src/rougail/cli/config.py:81
|
||||
msgid "Configuration in output step is in read_write mode"
|
||||
msgstr "La configuration dans l'état de sortie est dans mode lecture-écriture"
|
||||
|
||||
#: src/rougail/cli/config.py:84
|
||||
msgid "Type of variables description"
|
||||
msgstr "Type de description des variables"
|
||||
|
||||
#: src/rougail/cli/config.py:87
|
||||
msgid ""
|
||||
"To identify different variables, we use the variable description. There are "
|
||||
"four types of description:\n"
|
||||
"\n"
|
||||
" - path_and_description: which contains the variable path followed by "
|
||||
"its description\n"
|
||||
" - name_and_description: which contains the variable name followed by "
|
||||
"its description\n"
|
||||
" - path: the variable's path\n"
|
||||
" - name: the variable name\n"
|
||||
" - description: the variable's description"
|
||||
msgstr ""
|
||||
"Pour identifier les différentes variables, on utilise la description de la "
|
||||
"variable. Il y a quatre type de descriptions:\n"
|
||||
"\n"
|
||||
" - name_and_description : qui contient le nom de la variable suivi de "
|
||||
"sa description\n"
|
||||
" - path : le chemin de la variable\n"
|
||||
" - name : le nom de la variable\n"
|
||||
" - description : la description de la variable"
|
||||
|
||||
#: src/rougail/cli/config.py:103
|
||||
msgid "Modes that should not be accessible in read_only mode"
|
||||
msgstr "Modes quoi doivent être inaccessible en mode lecture seule"
|
||||
|
||||
#: src/rougail/cli/config.py:110 src/rougail/cli/config.py:127
|
||||
#: src/rougail/cli/config.py:145
|
||||
msgid "if any mode is set in \"modes_level\""
|
||||
msgstr "si aucun mode n'est défini dans \"modes_level\""
|
||||
|
||||
#: src/rougail/cli/config.py:117 src/rougail/cli/config.py:134
|
||||
#: src/rougail/cli/config.py:152
|
||||
msgid "mode must exists in \"modes_level\""
|
||||
msgstr "un mode doit exister dans \"modes_level\""
|
||||
|
||||
#: src/rougail/cli/config.py:120
|
||||
msgid "Modes that should not be accessible in read_write mode"
|
||||
msgstr "Modes quoi doivent être inaccessible en mode lecture-écriture"
|
||||
|
||||
#: src/rougail/cli/config.py:137
|
||||
msgid "Modes that should not be accessible"
|
||||
msgstr "Modes quoi doivent être inaccessible"
|
||||
|
||||
#~ msgid "do not display debug informations"
|
||||
#~ msgstr "ne pas afficher les informations de debug"
|
||||
|
||||
#~ msgid "do not display rougail version and all componants"
|
||||
#~ msgstr "ne pas afficher la version de rougail et de tous ces composants"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2024-10-31 19:17+0100\n"
|
||||
"POT-Creation-Date: 2026-01-04 19:07+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -15,15 +15,120 @@ msgstr ""
|
|||
"Generated-By: pygettext.py 1.5\n"
|
||||
|
||||
|
||||
#: src/rougail/cli/__main__.py:63
|
||||
#: src/rougail/cli/__main__.py:253
|
||||
msgid "cannot find \"user_data\" module \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/__main__.py:76
|
||||
#: src/rougail/cli/__main__.py:261
|
||||
msgid "interactive user data \"{0}\" is loader before uninteractive user data \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/__main__.py:297
|
||||
msgid "cannot find cli file for \"output_name\" module \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/__main__.py:89
|
||||
#: src/rougail/cli/__main__.py:328
|
||||
msgid "ERROR: {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:28
|
||||
msgid "Command line options"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:29
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:32
|
||||
msgid "Loads command line parameters from a file"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:40
|
||||
msgid "Displays debug informations"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:42
|
||||
msgid "Displays command line option warnings informations"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:44
|
||||
msgid "Displays Rougail version and all its components"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:46
|
||||
msgid "Invalid value in user data is not allowed"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:48
|
||||
msgid "Unknown variable in user data is not allowed"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:51
|
||||
msgid "Open each user data in separate layers"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:58
|
||||
msgid "if only one user data is set in \"__.step.user_data\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:65
|
||||
msgid "Use cache for load Tiramisu objects"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:67
|
||||
msgid "It will only be loaded from the cache if it already exists"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:69
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:76
|
||||
msgid "Use output only for the children variables of the family"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:77
|
||||
msgid "By default, all accessible variables are included in output. It is possible to define the family from which the output should be generated."
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:81
|
||||
msgid "Configuration in output step is in read_write mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:84
|
||||
msgid "Type of variables description"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:87
|
||||
msgid ""
|
||||
"To identify different variables, we use the variable description. There are four types of description:\n"
|
||||
"\n"
|
||||
" - path_and_description: which contains the variable path followed by its description\n"
|
||||
" - name_and_description: which contains the variable name followed by its description\n"
|
||||
" - path: the variable's path\n"
|
||||
" - name: the variable name\n"
|
||||
" - description: the variable's description"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:103
|
||||
msgid "Modes that should not be accessible in read_only mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:110 src/rougail/cli/config.py:127
|
||||
#: src/rougail/cli/config.py:145
|
||||
msgid "if any mode is set in \"modes_level\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:117 src/rougail/cli/config.py:134
|
||||
#: src/rougail/cli/config.py:152
|
||||
msgid "mode must exists in \"modes_level\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:120
|
||||
msgid "Modes that should not be accessible in read_write mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/cli/config.py:137
|
||||
msgid "Modes that should not be accessible"
|
||||
msgstr ""
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "rougail.cli"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0a41"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "CLI for Rougail"
|
||||
|
|
@ -13,11 +13,10 @@ license = {file = "LICENSE"}
|
|||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
|
|
@ -26,7 +25,7 @@ classifiers = [
|
|||
]
|
||||
dependencies = [
|
||||
"rougail >= 1.1,<2",
|
||||
"tiramisu_cmdline_parser >= 0.6,<1",
|
||||
"rougail-user-data-commandline",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
|
@ -40,5 +39,9 @@ name = "cz_conventional_commits"
|
|||
tag_format = "$version"
|
||||
version_scheme = "pep440"
|
||||
version_provider = "pep621"
|
||||
#update_changelog_on_bump = true
|
||||
version_files = [
|
||||
"src/rougail/cli/__version__.py",
|
||||
"pyproject.toml:version"
|
||||
]
|
||||
update_changelog_on_bump = true
|
||||
changelog_merge_prerelease = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -15,3 +15,5 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from .__version__ import __version__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -16,54 +16,233 @@ You should have received a copy of the GNU General Public License
|
|||
along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||
from tiramisu import Config
|
||||
import os
|
||||
from warnings import filterwarnings
|
||||
from pathlib import Path
|
||||
from sys import exit
|
||||
from warnings import warn
|
||||
|
||||
from rougail import Rougail, PropertiesOptionError
|
||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||
from tiramisu.error import PropertiesOptionError
|
||||
from tiramisu import MetaConfig
|
||||
|
||||
from rougail import Rougail
|
||||
from rougail.user_data import UserData
|
||||
from rougail.config import get_rougail_config
|
||||
from rougail.update import RougailUpgrade
|
||||
from rougail.utils import load_modules
|
||||
from rougail.error import RougailWarning
|
||||
|
||||
try:
|
||||
from rougail.user_data_yaml import RougailUserDataYaml
|
||||
except ImportError:
|
||||
RougailUserDataYaml = None
|
||||
try:
|
||||
from rougail.user_data_environment import RougailUserDataEnvironment
|
||||
except ImportError:
|
||||
RougailUserDataEnvironment = None
|
||||
from .rougailconfig import load as rougailconfig_load
|
||||
|
||||
from .i18n import _
|
||||
|
||||
|
||||
def _main():
|
||||
ENV_PREFIX = "ROUGAILCLI"
|
||||
|
||||
|
||||
def _main(arguments, do_not_print):
|
||||
global print_traceback
|
||||
rougailconfig = get_rougail_config(
|
||||
backward_compatibility=False, add_extra_options=False
|
||||
)
|
||||
cmd_config = load_cmd_user_data(rougailconfig, arguments)
|
||||
print_traceback = rougailconfig["cli.debug"]
|
||||
if rougailconfig["cli.versions"]:
|
||||
versions = display_version(cmd_config)
|
||||
if do_not_print:
|
||||
return list(versions)
|
||||
for version in versions:
|
||||
print(version)
|
||||
exit()
|
||||
layer_datas, metaconfig, config, err_warn = load_user_data(rougailconfig)
|
||||
output = get_output(rougailconfig,
|
||||
metaconfig,
|
||||
config,
|
||||
err_warn,
|
||||
layer_datas,
|
||||
)
|
||||
if do_not_print:
|
||||
return output.run()
|
||||
ret = output.print()
|
||||
if ret is False:
|
||||
exit(1)
|
||||
|
||||
|
||||
def load_cmd_user_data(rougailconfig, arguments):
|
||||
rougailconfig.generate_config()
|
||||
cmd_config = rougailconfig.config
|
||||
cmd_config.property.read_write()
|
||||
cmd_config.property.add("not_for_commandline")
|
||||
parser = TiramisuCmdlineParser(
|
||||
cmd_config,
|
||||
add_extra_options=False,
|
||||
short_name_max_len=2,
|
||||
origin_prop = cmd_config.property.default("read_write", "append")
|
||||
cmd_config.property.setdefault(
|
||||
frozenset(origin_prop | {"not_for_commandline"}), "read_write", "append"
|
||||
)
|
||||
parser.parse_args()
|
||||
cmd_config.property.remove("not_for_commandline")
|
||||
cmd_config.property.read_write()
|
||||
config_files = None
|
||||
if RougailUserDataYaml:
|
||||
_config_files = os.environ.pop(f"{ENV_PREFIX}_CLI.CONFIG_FILE", None)
|
||||
if _config_files:
|
||||
_config_files = _config_files.split(',')
|
||||
else:
|
||||
_config_files = cmd_config.forcepermissive.option("cli.config_file").value.get()
|
||||
_config_files = [_config_file for _config_file in _config_files if Path(_config_file).is_file()]
|
||||
if _config_files:
|
||||
config_files = _config_files
|
||||
if RougailUserDataEnvironment:
|
||||
env_prefix = ENV_PREFIX
|
||||
else:
|
||||
env_prefix = None
|
||||
user_data = rougailconfig_load(rougailconfig, config_files, env_prefix, True, _arguments=arguments, _generate=False, _add_help=False)
|
||||
display_warnings = rougailconfig["cli.warnings"]
|
||||
manage_warnings(display_warnings)
|
||||
if not cmd_config.option("cli.versions").value.get():
|
||||
if display_warnings and user_data["warnings"]:
|
||||
for warning in user_data["warnings"]:
|
||||
if isinstance(warning, dict):
|
||||
for w, var in warning.items():
|
||||
warn(UserWarning(f'unable to load "{var.option.impl_get_display_name(var)}", {str(w)}'))
|
||||
else:
|
||||
warn(warning)
|
||||
if manage_warnings:
|
||||
# replays to display errors if needed
|
||||
parser = TiramisuCmdlineParser(
|
||||
cmd_config,
|
||||
short_name_max_len=2,
|
||||
)
|
||||
parser.parse_args(arguments)
|
||||
if user_data["errors"]:
|
||||
raise Exception(user_data["errors"][0])
|
||||
|
||||
cmd_config.property.setdefault(origin_prop, "read_write", "append")
|
||||
cmd_config.property.read_only()
|
||||
if rougailconfig["upgrade"]:
|
||||
RougailUpgrade(rougailconfig=rougailconfig).run()
|
||||
return
|
||||
cmd_config.property.remove("not_for_commandline")
|
||||
|
||||
return cmd_config
|
||||
|
||||
|
||||
def display_version(cmd_config):
|
||||
versions = []
|
||||
from tiramisu import __version__
|
||||
yield(f"tiramisu: {__version__}")
|
||||
|
||||
from tiramisu_cmdline_parser import __version__
|
||||
yield(f"tiramisu-cmdline-parser: {__version__}")
|
||||
|
||||
from rougail import __version__
|
||||
yield(f"rougail: {__version__}")
|
||||
|
||||
from . import __version__
|
||||
yield(f"rougail-cli: {__version__}")
|
||||
|
||||
for step in ["structural", "user_data", "output"]:
|
||||
display_step = step.replace("_", "-")
|
||||
for step_name in sorted(cmd_config.unrestraint.option(f"step.{step}").value.list()):
|
||||
path = (
|
||||
Path(__file__).parent.parent
|
||||
/ (step + "_" + step_name)
|
||||
/ "__init__.py"
|
||||
)
|
||||
if path.is_file():
|
||||
try:
|
||||
module = load_modules(
|
||||
"rougail." + step + "_" + step_name, str(path)
|
||||
)
|
||||
yield(
|
||||
f"rougail-{display_step}-{step_name}: {module.__version__}"
|
||||
)
|
||||
except Exception as err:
|
||||
pass
|
||||
|
||||
|
||||
def manage_warnings(warnings):
|
||||
if not warnings:
|
||||
filterwarnings("ignore", category=DeprecationWarning)
|
||||
filterwarnings("ignore", category=RougailWarning)
|
||||
else:
|
||||
filterwarnings("default", category=DeprecationWarning)
|
||||
filterwarnings("default", category=RougailWarning)
|
||||
|
||||
|
||||
def load_user_data(rougailconfig):
|
||||
layer_datas = {}
|
||||
if not rougailconfig["cli.load_config"]:
|
||||
return None, None, None, {"errors": [], "warnings": []}
|
||||
try:
|
||||
user_data_names = rougailconfig["step.user_data"]
|
||||
except PropertiesOptionError:
|
||||
user_data_names = []
|
||||
output_name = rougailconfig["step.output"]
|
||||
# structural
|
||||
rougail = Rougail(rougailconfig)
|
||||
for user_data_name in user_data_names:
|
||||
rougail.converted.plugins.append("user_data_" + user_data_name)
|
||||
rougail.converted.plugins.append("output_" + output_name)
|
||||
config = rougail.get_config()
|
||||
# data user
|
||||
if not user_data_names:
|
||||
user_datas = None
|
||||
has_layers = rougailconfig["cli.layers"]
|
||||
if has_layers:
|
||||
layers = [[ud] for ud in user_data_names]
|
||||
last_layers = len(layers) - 1
|
||||
else:
|
||||
config.property.read_write()
|
||||
user_datas = []
|
||||
for user_data_name in user_data_names:
|
||||
layers = [user_data_names]
|
||||
last_layers = 0
|
||||
if rougailconfig["tiramisu_cache"]:
|
||||
load_from_tiramisu_cache = rougailconfig["cli.load_from_tiramisu_cache"]
|
||||
else:
|
||||
load_from_tiramisu_cache = False
|
||||
rougail = Rougail(rougailconfig, load_from_tiramisu_cache=load_from_tiramisu_cache)
|
||||
layer_name = "_".join(layers[-1])
|
||||
subconfig = rougail.run(name=layer_name)
|
||||
try:
|
||||
read_write = set()
|
||||
read_only = set()
|
||||
if rougailconfig["cli.inaccessible_read_write_modes"]:
|
||||
read_write = set(rougailconfig["cli.inaccessible_read_write_modes"])
|
||||
if rougailconfig["cli.inaccessible_read_only_modes"]:
|
||||
read_only = set(rougailconfig["cli.inaccessible_read_only_modes"])
|
||||
if rougailconfig["cli.inaccessible_modes"]:
|
||||
modes = set(rougailconfig["cli.inaccessible_modes"])
|
||||
read_only |= modes
|
||||
read_write |= modes
|
||||
if read_write:
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_write", "append") | read_write), "read_write", "append"
|
||||
)
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_only", "remove") | (read_write - read_only)), "read_only", "remove"
|
||||
)
|
||||
for p in read_write:
|
||||
subconfig.permissive.add(p)
|
||||
if read_only:
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_only", "append") | read_only), "read_only", "append"
|
||||
)
|
||||
for p in read_only:
|
||||
subconfig.permissive.add(p)
|
||||
if read_write or read_only:
|
||||
subconfig.property.read_write()
|
||||
except:
|
||||
pass
|
||||
subconfig.information.set("description_type", rougailconfig["cli.description_type"])
|
||||
metaconfig = subconfig
|
||||
if last_layers:
|
||||
for layer in reversed(layers[:-1]):
|
||||
layer_name = "_".join(layer)
|
||||
metaconfig = MetaConfig([metaconfig], name=layer_name)
|
||||
metaconfig.owner.set(metaconfig.path())
|
||||
subconfig = metaconfig
|
||||
err_warn = {"errors": [], "warnings": []}
|
||||
invalid_user_data_error = rougailconfig["cli.invalid_user_data_error"]
|
||||
unknown_user_data_error = rougailconfig["cli.unknown_user_data_error"]
|
||||
interactive_user_data = {}
|
||||
for idx, layer in enumerate(layers):
|
||||
if idx:
|
||||
subconfig = subconfig.config("_".join(layer))
|
||||
subconfig.owner.set(subconfig.path())
|
||||
layer_name = subconfig.path()
|
||||
# data user
|
||||
user_data = []
|
||||
if has_layers:
|
||||
layer_datas[layer_name] = {}
|
||||
for user_data_name in layer:
|
||||
path = (
|
||||
Path(__file__).parent.parent
|
||||
/ ("user_data_" + user_data_name)
|
||||
|
|
@ -74,35 +253,76 @@ def _main():
|
|||
_('cannot find "user_data" module "{0}"').format(user_data_name)
|
||||
)
|
||||
module = load_modules("rougail.user_data_" + user_data_name, str(path))
|
||||
user_datas.extend(
|
||||
module.RougailUserData(
|
||||
config,
|
||||
rougail_user_data = module.RougailUserData
|
||||
if hasattr(rougail_user_data, 'interactive_user_data') and rougail_user_data.interactive_user_data:
|
||||
interactive_user_data.setdefault(layer_name, {})[user_data_name] = rougail_user_data
|
||||
continue
|
||||
elif interactive_user_data:
|
||||
raise Exception(_('interactive user data "{0}" is loader before uninteractive user data "{1}"').format(list(interactive_user_data), user_data_name))
|
||||
for ud in rougail_user_data(
|
||||
subconfig,
|
||||
rougailconfig=rougailconfig,
|
||||
).run()
|
||||
)
|
||||
if user_datas:
|
||||
err_warn = rougail.user_datas(user_datas)
|
||||
else:
|
||||
err_warn = {"errors": [], "warnings": []}
|
||||
).run():
|
||||
if has_layers:
|
||||
layer_datas[layer_name].setdefault(user_data_name, []).append(ud["source"])
|
||||
user_data.append(ud)
|
||||
if user_data:
|
||||
new_err_warn = UserData(subconfig).user_data(user_data, invalid_user_data_error=invalid_user_data_error, unknown_user_data_error=unknown_user_data_error)
|
||||
for level, datas in new_err_warn.items():
|
||||
if datas:
|
||||
err_warn[level].extend(datas)
|
||||
for layer_name, interactive_user_data in interactive_user_data.items():
|
||||
for layer, rougail_user_data in interactive_user_data.items():
|
||||
if has_layers and len(layers) > 1:
|
||||
subconfig = subconfig.config("_".join(layer))
|
||||
subconfig.owner.set(subconfig.path())
|
||||
for user_data in rougail_user_data(
|
||||
subconfig,
|
||||
rougailconfig=rougailconfig,
|
||||
).run():
|
||||
if has_layers:
|
||||
layer_datas[layer_name].setdefault(user_data_name, []).append(user_data["source"])
|
||||
|
||||
return layer_datas, metaconfig, subconfig, err_warn
|
||||
|
||||
|
||||
def get_output(rougailconfig, metaconfig, config, err_warn, layer_datas):
|
||||
# output
|
||||
config.property.read_only()
|
||||
if config and (not rougailconfig["cli.load_config"] or not rougailconfig["cli.read_write"]):
|
||||
config.property.read_only()
|
||||
output_name = rougailconfig["step.output"]
|
||||
path = Path(__file__).parent.parent / ("output_" + output_name) / "__init__.py"
|
||||
if not path.is_file():
|
||||
raise Exception(
|
||||
_('cannot find cli file for "output_name" module "{0}"').format(output_name)
|
||||
)
|
||||
module = load_modules("rougail.output_" + output_name, str(path))
|
||||
module.RougailOutput(
|
||||
config=config,
|
||||
root = rougailconfig["cli.root"]
|
||||
if root:
|
||||
subconfig = config.option(root)
|
||||
else:
|
||||
subconfig = config
|
||||
output = module.RougailOutput(
|
||||
config=subconfig,
|
||||
true_config=config,
|
||||
rougailconfig=rougailconfig,
|
||||
user_data_errors=err_warn["errors"],
|
||||
user_data_warnings=err_warn["warnings"],
|
||||
).run()
|
||||
config_owner_is_path=True,
|
||||
root_config=metaconfig,
|
||||
layer_datas=layer_datas,
|
||||
)
|
||||
return output
|
||||
|
||||
|
||||
def main():
|
||||
def main(arguments=None, do_not_print=False):
|
||||
global print_traceback
|
||||
print_traceback = True
|
||||
try:
|
||||
_main()
|
||||
return _main(arguments, do_not_print)
|
||||
except Exception as err:
|
||||
print(_("ERROR: {0}").format(err))
|
||||
exit(1)
|
||||
if print_traceback:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
exit(_("ERROR: {0}").format(err))
|
||||
|
|
|
|||
1
src/rougail/cli/__version__.py
Normal file
1
src/rougail/cli/__version__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__version__ = "0.2.0a41"
|
||||
177
src/rougail/cli/config.py
Normal file
177
src/rougail/cli/config.py
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
"""
|
||||
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
|
||||
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.')}
|
||||
|
||||
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')}
|
||||
|
||||
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,
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
"""Internationalisation utilities
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024
|
||||
Copyright (C) 2024-2026
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,6 +19,6 @@ along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
|||
from gettext import translation
|
||||
from pathlib import Path
|
||||
|
||||
t = translation("rougail_cli", str(Path(__file__).parent / "locale"))
|
||||
t = translation("rougail_cli", str(Path(__file__).parent / "locale"), fallback=True)
|
||||
|
||||
_ = t.gettext
|
||||
|
|
|
|||
Binary file not shown.
83
src/rougail/cli/rougailconfig.py
Normal file
83
src/rougail/cli/rougailconfig.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
"""
|
||||
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 General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Mtools 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Mtools. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from rougail.user_data import UserData
|
||||
|
||||
|
||||
def load(rougailconfig: "RougailConfig",
|
||||
yaml_files: list[str]=None,
|
||||
env_prefix: str=None,
|
||||
commandline: bool=False,
|
||||
_arguments=None,
|
||||
_add_help=True,
|
||||
_generate=True
|
||||
):
|
||||
if _generate:
|
||||
rougailconfig.generate_config()
|
||||
cmd_config = rougailconfig.config
|
||||
origin_prop = cmd_config.property.exportation()
|
||||
cmd_config.property.read_write()
|
||||
user_data = []
|
||||
if yaml_files:
|
||||
for yaml_file in yaml_files:
|
||||
user_data.extend(from_yaml(cmd_config, yaml_file))
|
||||
if env_prefix:
|
||||
user_data.extend(from_env(cmd_config, env_prefix))
|
||||
if commandline:
|
||||
user_data.extend(from_cmdline(cmd_config, _arguments, _add_help))
|
||||
user_data = UserData(cmd_config).user_data(user_data)
|
||||
cmd_config.property.importation(origin_prop)
|
||||
return user_data
|
||||
|
||||
|
||||
def from_yaml(cmd_config, yaml_file):
|
||||
from rougail.user_data_yaml import RougailUserDataYaml
|
||||
fake_rougail_config = {
|
||||
"step.user_data": ["yaml"],
|
||||
"yaml.filename": [yaml_file],
|
||||
"yaml.file_with_secrets": "all",
|
||||
}
|
||||
return RougailUserDataYaml(cmd_config,
|
||||
rougailconfig=fake_rougail_config,
|
||||
).run()
|
||||
|
||||
|
||||
def from_env(cmd_config, env_prefix):
|
||||
from rougail.user_data_environment import RougailUserDataEnvironment
|
||||
fake_rougail_config = {
|
||||
"main_namespace": None,
|
||||
"step.user_data": ["environment"],
|
||||
"environment.default_environment_name": env_prefix,
|
||||
"environment.custom_separator": None,
|
||||
}
|
||||
return RougailUserDataEnvironment(
|
||||
cmd_config,
|
||||
rougailconfig=fake_rougail_config,
|
||||
).run()
|
||||
|
||||
|
||||
def from_cmdline(cmd_config, arguments, add_help):
|
||||
from rougail.user_data_commandline import RougailUserDataCommandline
|
||||
fake_rougail_config = {
|
||||
"step.user_data": ["commandline"],
|
||||
}
|
||||
return RougailUserDataCommandline(cmd_config,
|
||||
rougailconfig=fake_rougail_config,
|
||||
short_name_max_len=2,
|
||||
arguments=arguments,
|
||||
add_help=add_help,
|
||||
).run()
|
||||
5
tests/cli/result.txt
Normal file
5
tests/cli/result.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
╭─────── Caption ────────╮
|
||||
│ Variable [38;5;220mDefault value[0m │
|
||||
╰────────────────────────╯
|
||||
Variables:
|
||||
[94m┗━━ [0m📓 a description: [38;5;220mmy_value[0m
|
||||
7
tests/cli/result_user_data.txt
Normal file
7
tests/cli/result_user_data.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
╭────────────── Caption ───────────────╮
|
||||
│ Variable [32mModified value[0m │
|
||||
│ (⏳ Original default value) │
|
||||
╰──────────────────────────────────────╯
|
||||
Variables:
|
||||
[94m┗━━ [0m📓 a description: [32ma yaml value[0m ◀ loaded from the YAML file "yaml/file.yml"
|
||||
[94m [0m(⏳ my_value)
|
||||
7
tests/cli/result_user_datas.txt
Normal file
7
tests/cli/result_user_datas.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
╭────────────── Caption ───────────────╮
|
||||
│ Variable [32mModified value[0m │
|
||||
│ (⏳ Original default value) │
|
||||
╰──────────────────────────────────────╯
|
||||
Variables:
|
||||
[94m┗━━ [0m📓 a description: [32ma yaml value[0m ◀ loaded from the YAML file "yaml/file.yml"
|
||||
[94m [0m(⏳ my_value)
|
||||
12
tests/cli/result_user_datas_layers.txt
Normal file
12
tests/cli/result_user_datas_layers.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
╭────────────── Caption ───────────────╮
|
||||
│ Variable [32mModified value[0m │
|
||||
│ (⏳ Original default value) │
|
||||
╰──────────────────────────────────────╯
|
||||
╭─────────── Layers ────────────╮
|
||||
│ environment variable │
|
||||
│ the YAML file "yaml/file.yml" │
|
||||
│ Bitwarden │
|
||||
╰───────────────────────────────╯
|
||||
Variables:
|
||||
[94m┗━━ [0m📓 a description: [32ma yaml value[0m ◀ loaded from the YAML file "yaml/file.yml"
|
||||
[94m [0m(⏳ my env value ◀ loaded from environment variable ⏳ my_value)
|
||||
4
tests/cli/structures/file.yml
Normal file
4
tests/cli/structures/file.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable: my_value # a description
|
||||
1
tests/cli/versions.txt
Normal file
1
tests/cli/versions.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
["tiramisu", "tiramisu-cmdline-parser", "rougail", "rougail-cli", "rougail-user-data-ansible", "rougail-user-data-bitwarden", "rougail-user-data-commandline", "rougail-user-data-environment", "rougail-user-data-questionary", "rougail-user-data-yaml", "rougail-output-ansible", "rougail-output-display", "rougail-output-doc", "rougail-output-json", "rougail-output-table"]
|
||||
2
tests/cli/yaml/file.yml
Normal file
2
tests/cli/yaml/file.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
my_variable: a yaml value
|
||||
7
tests/rougailcli_file/.rougailcli.yml
Normal file
7
tests/rougailcli_file/.rougailcli.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
step:
|
||||
output: doc
|
||||
doc:
|
||||
output_format: json
|
||||
1
tests/rougailcli_file/alt_console.txt
Normal file
1
tests/rougailcli_file/alt_console.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n\u2503\u001b[1m \u001b[0m\u001b[1mVariable \u001b[0m\u001b[1m \u001b[0m\u2503\u001b[1m \u001b[0m\u001b[1mDescription \u001b[0m\u001b[1m \u001b[0m\u2503\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2529\n\u2502 \u001b[1mmy_variable\u001b[0m \u2502 A description. \u2502\n\u2502 \u001b[1;7m string \u001b[0m \u001b[1;7m mandatory \u001b[0m \u2502 \u001b[1mDefault\u001b[0m: my_value \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"
|
||||
7
tests/rougailcli_file/alt_rougailcli.yml
Normal file
7
tests/rougailcli_file/alt_rougailcli.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
step:
|
||||
output: doc
|
||||
doc:
|
||||
output_format: console
|
||||
1
tests/rougailcli_file/choice_console.txt
Normal file
1
tests/rougailcli_file/choice_console.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Caption \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 Variable \u001b[38;5;220mDefault value\u001b[0m \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\nVariables:\n\u001b[94m\u2517\u2501\u2501 \u001b[0m\ud83d\udcd3 a description: \u001b[38;5;220mmy_value\u001b[0m\n"
|
||||
8
tests/rougailcli_file/choice_rougailcli.yml
Normal file
8
tests/rougailcli_file/choice_rougailcli.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
- structures_warnings
|
||||
doc:
|
||||
output_format: console
|
||||
cli:
|
||||
warnings: false
|
||||
1
tests/rougailcli_file/mix_console.txt
Normal file
1
tests/rougailcli_file/mix_console.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"[cols=\"1a,1a\"]\n|====\n| Variable | Description \n| **my_variable** +\n`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `mandatory` | A description. +\n**Default**: my_value \n|====\n\n"
|
||||
6
tests/rougailcli_file/mix_rougailcli.yml
Normal file
6
tests/rougailcli_file/mix_rougailcli.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
doc:
|
||||
output_format: console
|
||||
|
||||
4
tests/rougailcli_file/structures/file.yml
Normal file
4
tests/rougailcli_file/structures/file.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable: my_value # a description
|
||||
11
tests/rougailcli_file/structures_warnings/file.yml
Normal file
11
tests/rougailcli_file/structures_warnings/file.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable:
|
||||
redefine: true
|
||||
validators: # validators in jinja without description makes warnings
|
||||
- jinja: |-
|
||||
{{ _.my_variable != "my_value" }}
|
||||
return_type: boolean
|
||||
description: '"_.my_variable" must not be my_value'
|
||||
warnings: true
|
||||
1
tests/rougailcli_file/symlink_rougailcli.txt
Normal file
1
tests/rougailcli_file/symlink_rougailcli.txt
Normal 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\""]
|
||||
4
tests/rougailcli_file/symlink_rougailcli.yml
Normal file
4
tests/rougailcli_file/symlink_rougailcli.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
s: doc
|
||||
1
tests/rougailcli_file/warnings.txt
Normal file
1
tests/rougailcli_file/warnings.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
["unable to load \"test mandatories variables before display in JSON\", family \"Export configuration to JSON format\" has property disabled, so cannot access to \"test mandatories variables before display in JSON\", it will be ignored when loading from the YAML file \"warnings.yml\""]
|
||||
7
tests/rougailcli_file/warnings.yml
Normal file
7
tests/rougailcli_file/warnings.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
doc:
|
||||
output_format: console
|
||||
json:
|
||||
mandatory: true
|
||||
1
tests/rougailcli_file/warnings2.txt
Normal file
1
tests/rougailcli_file/warnings2.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
9
tests/rougailcli_file/warnings2.yml
Normal file
9
tests/rougailcli_file/warnings2.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
doc:
|
||||
output_format: console
|
||||
json:
|
||||
mandatory: true
|
||||
cli:
|
||||
warnings: false
|
||||
1
tests/rougailcli_file/warnings3.txt
Normal file
1
tests/rougailcli_file/warnings3.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
["unable to load \"test mandatories variables before display in JSON\", family \"Export configuration to JSON format\" has property disabled, so cannot access to \"test mandatories variables before display in JSON\", it will be ignored when loading from the YAML file \"warnings3.yml\""]
|
||||
8
tests/rougailcli_file/warnings3.yml
Normal file
8
tests/rougailcli_file/warnings3.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
- structures_warnings
|
||||
doc:
|
||||
output_format: console
|
||||
json:
|
||||
mandatory: true
|
||||
1
tests/rougailcli_file/warnings4.txt
Normal file
1
tests/rougailcli_file/warnings4.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
10
tests/rougailcli_file/warnings4.yml
Normal file
10
tests/rougailcli_file/warnings4.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
- structures_warnings
|
||||
doc:
|
||||
output_format: console
|
||||
json:
|
||||
mandatory: true
|
||||
cli:
|
||||
warnings: false
|
||||
1
tests/rougailcli_file/yaml.txt
Normal file
1
tests/rougailcli_file/yaml.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"variable_type\": \"string\",\n \"path\": \"my_variable\",\n \"names\": [\n \"my_variable\"\n ],\n \"description\": \"A description.\",\n \"properties\": [\n {\n \"type\": \"property\",\n \"name\": \"mandatory\",\n \"ori_name\": \"mandatory\",\n \"access_control\": false\n }\n ],\n \"gen_examples\": [\n \"my_value\"\n ],\n \"mandatory_without_value\": false\n }\n}"
|
||||
5
tests/rougailcli_files/rougailcli1.yml
Normal file
5
tests/rougailcli_files/rougailcli1.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
main_structural_directories:
|
||||
- structures
|
||||
step:
|
||||
output: json
|
||||
5
tests/rougailcli_files/rougailcli2.yml
Normal file
5
tests/rougailcli_files/rougailcli2.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
step:
|
||||
output: doc
|
||||
doc:
|
||||
output_format: json
|
||||
4
tests/rougailcli_files/structures/file.yml
Normal file
4
tests/rougailcli_files/structures/file.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable: my_value # a description
|
||||
1
tests/rougailcli_files/yaml.txt
Normal file
1
tests/rougailcli_files/yaml.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"variable_type\": \"string\",\n \"path\": \"my_variable\",\n \"names\": [\n \"my_variable\"\n ],\n \"description\": \"A description.\",\n \"properties\": [\n {\n \"type\": \"property\",\n \"name\": \"mandatory\",\n \"ori_name\": \"mandatory\",\n \"access_control\": false\n }\n ],\n \"gen_examples\": [\n \"my_value\"\n ],\n \"mandatory_without_value\": false\n }\n}"
|
||||
3
tests/second_step/.rougailcli.yml
Normal file
3
tests/second_step/.rougailcli.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
doc:
|
||||
output_format: json
|
||||
4
tests/second_step/structures/file.yml
Normal file
4
tests/second_step/structures/file.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
version: 1.1
|
||||
|
||||
my_variable: my_value # a description
|
||||
1
tests/second_step/yaml.txt
Normal file
1
tests/second_step/yaml.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
"{\n \"my_variable\": {\n \"type\": \"variable\",\n \"default\": {\n \"name\": \"Default\",\n \"values\": \"my_value\"\n },\n \"variable_type\": \"string\",\n \"path\": \"my_variable\",\n \"names\": [\n \"my_variable\"\n ],\n \"description\": \"A description.\",\n \"properties\": [\n {\n \"type\": \"property\",\n \"name\": \"mandatory\",\n \"ori_name\": \"mandatory\",\n \"access_control\": false\n }\n ],\n \"gen_examples\": [\n \"my_value\"\n ],\n \"mandatory_without_value\": false\n }\n}"
|
||||
309
tests/test_load.py
Normal file
309
tests/test_load.py
Normal file
|
|
@ -0,0 +1,309 @@
|
|||
import os
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from contextlib import chdir
|
||||
from json import dumps, loads
|
||||
|
||||
from rougail.cli.__main__ import main
|
||||
|
||||
|
||||
test_dir = Path(__file__).parent
|
||||
os.environ['COLUMNS'] = '80'
|
||||
|
||||
|
||||
def test_cli():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures'], do_not_print=True)
|
||||
filename = Path('result.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_boolean():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--display.mandatory'], do_not_print=True)
|
||||
filename = Path('result.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_boolean_no():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--display.no-mandatory'], do_not_print=True)
|
||||
filename = Path('result.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_version():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--cli.version'], do_not_print=True)
|
||||
ret = [r.rsplit(': ', 1)[0] for r in ret]
|
||||
filename = Path('versions.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == data, str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_version_user_data_disabled():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--cli.version', '--step.output', 'doc'], do_not_print=True)
|
||||
ret = [r.rsplit(': ', 1)[0] for r in ret]
|
||||
filename = Path('versions.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == data, str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_version_user_data_disabled_2():
|
||||
with chdir(test_dir / 'second_step'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--step.output', 'doc'], do_not_print=True)
|
||||
filename = Path('yaml.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_user_data():
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--step.user_data', 'yaml', '--yaml.filename', 'yaml/file.yml'], do_not_print=True)
|
||||
filename = Path('result_user_data.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_user_datas():
|
||||
save = os.environ.copy()
|
||||
os.environ["MY_VARIABLE"] = "my env value"
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--step.user_data', 'environment', 'yaml', '--yaml.filename', 'yaml/file.yml'], do_not_print=True)
|
||||
filename = Path('result_user_datas.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
save = os.environ.copy()
|
||||
|
||||
|
||||
def test_cli_user_datas_user_datas_layers():
|
||||
save = os.environ.copy()
|
||||
os.environ["ROUGAIL_MY_VARIABLE"] = "my env value"
|
||||
with chdir(test_dir / 'cli'):
|
||||
ret = main(['--main_structural_directories', 'structures', '--cli.layers', '--step.user_data', 'environment', 'yaml', 'bitwarden', '--yaml.filename', 'yaml/file.yml', '--bitwarden.mock_enable'], do_not_print=True)
|
||||
filename = Path('result_user_datas_layers.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(ret[1])
|
||||
with filename.open() as fh:
|
||||
data = fh.read()
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
save = os.environ.copy()
|
||||
|
||||
|
||||
def test_cli_tiramis_cache():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
tmp_file = Path("tmp/tiramisu.py")
|
||||
tmp_file.parent.mkdir(exist_ok=True)
|
||||
tmp_file.unlink(missing_ok=True)
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'choice_rougailcli.yml'
|
||||
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', '--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:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
tmp_file.unlink()
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli():
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
ret = main([], do_not_print=True)
|
||||
filename = Path('yaml.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_rougailcli_files():
|
||||
with chdir(test_dir / 'rougailcli_files'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'rougailcli1.yml,rougailcli2.yml'
|
||||
ret = main([], do_not_print=True)
|
||||
filename = Path('yaml.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
|
||||
|
||||
def test_cli_alt_rougailcli():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'alt_rougailcli.yml'
|
||||
ret = main([], do_not_print=True)
|
||||
filename = Path('alt_console.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli_mix():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'mix_rougailcli.yml'
|
||||
ret = main(["-o", "doc", "--doc.output_format", "asciidoc"], do_not_print=True)
|
||||
filename = Path('mix_console.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == (True, data), str(filename.absolute())
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli_warning():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings.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('warnings.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
|
||||
|
||||
|
||||
def test_cli_rougailcli_not_warning():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings2.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)
|
||||
filename = Path('warnings2.txt')
|
||||
ret = [str(w.message) for w in rougail_wn]
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == data, str(filename.absolute())
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli_warning2():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings3.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('warnings3.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == data, str(filename.absolute())
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli_not_warning2():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'warnings4.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)
|
||||
filename = Path('warnings4.txt')
|
||||
ret = [str(w.message) for w in rougail_wn]
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret))
|
||||
with filename.open() as fh:
|
||||
data = loads(fh.read())
|
||||
assert ret == data, str(filename.absolute())
|
||||
os.environ = save
|
||||
|
||||
|
||||
def test_cli_rougailcli_choice():
|
||||
save = os.environ.copy()
|
||||
with chdir(test_dir / 'rougailcli_file'):
|
||||
os.environ["ROUGAILCLI_CLI.CONFIG_FILE"] = 'choice_rougailcli.yml'
|
||||
ret = main([], do_not_print=True)
|
||||
filename = Path('choice_console.txt')
|
||||
if not filename.is_file():
|
||||
with filename.open('w') as fh:
|
||||
fh.write(dumps(ret[1]))
|
||||
with filename.open() as fh:
|
||||
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
|
||||
Loading…
Reference in a new issue