custom type update

This commit is contained in:
gwen 2026-03-21 17:33:46 +01:00
parent e840bc5289
commit 5039060012

View file

@ -30,20 +30,20 @@ HTTP Proxy with "proxy" type
In this section we will look at the possibilities for adding types. In this section we will look at the possibilities for adding types.
This feature is essential for having a truly adaptable tool. This feature is essential for having a truly adaptable tool.
It's possible to add basic types, but that involves modifying .. note:: It is actually possible to add static predefined types,
the tiramisu recipe itself. but that involves modifying the :term:`tiramisu` library itself.
More simply, it's possible to create custom types, much like defining families.
Our structural folder will be expanded a bit: More simply, it's possible in Rougail to create custom types, much like defining families.
Our folder structure will be expanded a bit:
.. raw:: html .. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/tree.html :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/tree.html
Notice that we have now a new :file:`types` folder in our tree structure. Notice that we have now a new :file:`types` folder in our tree structure.
This is where we will define our new types. This is where we place our new type definitions.
And we also have a new structure file named :file:`00-proxy.yml`. Let's examine them more closely this new structure file named :file:`types/proxy/00_type.yml`:
Let's examine them more closely.
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/types/proxy/00_type.yml .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/types/proxy/00_type.yml
:language: yaml :language: yaml
@ -71,6 +71,58 @@ Let's examine them more closely.
variable: __.http_proxy.port variable: __.http_proxy.port
... ...
Now a new type named `proxy` is declared.
It's more or less like a family except it will be used as a type definition,
.. questions:: How do we use a new type?
Very simply. In the usual way.
Here, we will declare that a family is of type `proxy` as follows:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/firefox/10-manual.yml
:language: yaml
:caption: The :file:`firefox/10-manual.yml` structure file with less code due to the `proxy` type definition
..
%YAML 1.2
---
version: 1.1
manual:
description: Manual proxy configuration
disabled:
variable: _.proxy_mode
when_not: Manual proxy configuration
http_proxy:
description: HTTP Proxy
type: proxy
address:
default: null
port:
default: 8080
...
We can see that the `http_proxy` family has the `type: proxy` declared. Very simple.
So we have declared our new type. How do you make it available in our structure file definitions?
The Rougail CLI with the type declaration command line option:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt
:class: terminal
The output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html
:class: output
TODO: TODO:
@ -78,6 +130,7 @@ TODO:
- la notion de type vient de la déclaration ligne de commande --type - la notion de type vient de la déclaration ligne de commande --type
rougail -m firefox/ --types types/proxy -u yaml -yf config/01/config.yml rougail -m firefox/ --types types/proxy -u yaml -yf config/01/config.yml
- le fichier firefox/10-manual.yml a des changements - le fichier firefox/10-manual.yml a des changements
https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_080~1..v1.1_080 https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_080~1..v1.1_080
dégraissage dû à la déclaration de type dégraissage dû à la déclaration de type
@ -98,24 +151,4 @@ TODO:
┣━━ 📓 SOCKS port: 3128 ┣━━ 📓 SOCKS port: 3128
┗━━ 📓 SOCKS host version used by proxy: v5 ┗━━ 📓 SOCKS host version used by proxy: v5
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/types/proxy/00_type.yml
:language: yaml
:caption: The :file:`types/proxy/00_type.yml` structure file with proxy type declaration
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/firefox/10-manual.yml
:language: yaml
:caption: The :file:`firefox/10-manual.yml` structure file with less declaration due to the type definition
The Rougail CLI with the type declaration command line option:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt
:class: terminal
The output:
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html
:class: output