update custom type

This commit is contained in:
gwen 2026-03-23 17:46:27 +01:00
parent 5039060012
commit 847205938d
2 changed files with 21 additions and 17 deletions

View file

@ -63,7 +63,6 @@ Rougail
:caption: Load values from user datas :caption: Load values from user datas
user_datas/index user_datas/index
configuration
.. toctree:: .. toctree::
:titlesonly: :titlesonly:

View file

@ -3,7 +3,7 @@ Custom type
.. objectives:: Objectives .. objectives:: Objectives
We are going to learn how to create custom types. In this sections we are going to learn how to create custom types.
In short, a custom type is nothing more than a kind of family template. In short, a custom type is nothing more than a kind of family template.
.. prerequisites:: Prerequisites .. prerequisites:: Prerequisites
@ -27,11 +27,12 @@ Custom type
HTTP Proxy with "proxy" type HTTP Proxy with "proxy" type
-------------------------------- --------------------------------
In this section we will look at the possibilities for adding types. Let's look now 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.
.. note:: It is actually possible to add static predefined types, .. note:: It is actually possible to add types,
but that involves modifying the :term:`tiramisu` library itself. but that involves adding predefined types to the :term:`tiramisu` underlying consistency library itself,
and thats a different matter altogether. There is a simpler way to do this.
More simply, it's possible in Rougail to create custom types, much like defining families. More simply, it's possible in Rougail to create custom types, much like defining families.
@ -41,9 +42,11 @@ Our folder structure will be expanded a bit:
: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 place our new type definitions. This is where we place our new `proxy` type definition.
Let's examine them more closely this new structure file named :file:`types/proxy/00_type.yml`: In accordance with our :ref:`naming policy <namingconvention>`, we have created a file named :file:`00_type.yml`
inside the `proxy` folder.
Let's examine this more closely this :file:`types/proxy/00_type.yml` type definition file:
.. 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,13 +74,12 @@ Let's examine them more closely this new structure file named :file:`types/proxy
variable: __.http_proxy.port variable: __.http_proxy.port
... ...
Now a new type named `proxy` is declared. The new type named `proxy` is declared.
It's more or less like a family except it will be used as a type definition, It's more or less like a family declaration except it will be used as a type definition.
.. questions:: How do we use a new type? .. questions:: How do we use a new type?
Very simply. In the usual way. Very simply. In the usual way: we will use the `type` parameter.
Here, we will declare that a family is of type `proxy` as follows: Here, we will declare that a family is of type `proxy` as follows:
@ -107,17 +109,16 @@ It's more or less like a family except it will be used as a type definition,
default: 8080 default: 8080
... ...
We can see that the `http_proxy` family has the `type: proxy` declared. Very simple. We can see that the type declared for the `http_proxy` family is `type: proxy`. Very simple.
So we have declared our new type. How do you make it available in our structure file definitions? So we have declared our new type. How do we make it available? Well, the Rougail CLI has a `--types` type declaration command line option.
Let's launch the rougail CLI:
The Rougail CLI with the type declaration command line option:
.. raw:: html .. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt
:class: terminal :class: terminal
The output: The output is:
.. raw:: html .. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html
@ -151,4 +152,8 @@ TODO:
┣━━ 📓 SOCKS port: 3128 ┣━━ 📓 SOCKS port: 3128
┗━━ 📓 SOCKS host version used by proxy: v5 ┗━━ 📓 SOCKS host version used by proxy: v5
.. keypoints:: Key points
- type declaration
- type usage
-