boolean var

This commit is contained in:
gwen 2025-05-14 13:17:08 +02:00
parent edde6e2a85
commit 284a176a0a
4 changed files with 100 additions and 7 deletions

93
docs/tutorial/boolean.rst Normal file
View file

@ -0,0 +1,93 @@
A new variable which has the `boolean` type
===============================================
.. objectives:: Objectives
In this section we will learn:
- how to make a boolean type variable
.. prerequisites:: Reminders
Let's summarize the configuration up to here
Whe have the `proxy_mode` configuration here:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/00-proxy.yml
:language: yaml
:caption: firefox/00-proxy.yml
..
---
proxy_mode:
description: Configure Proxy Access to the Internet
choices:
- No proxy
- Auto-detect proxy settings for this network
- Use system proxy settings
- Manual proxy configuration
- Automatic proxy configuration URL
default: No proxy
With the manual subfamily in case of the "Manual proxy configuration" configuration option has been chosen:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/10-manual.yml
:language: yaml
:caption: firefox/10-manual.yml
..
---
manual:
description: Manual proxy configuration
disabled:
variable: proxy_mode
when_not: 'Manual proxy configuration'
http_proxy:
description: HTTP Proxy
address:
description: HTTP address
type: domainname
params:
allow_ip: true
port:
description: HTTP Port
type: port
default: 8080
.. type-along:: The HTTPS mode
Now we will focus on configuring the HTTPS mode in case of "Manual proxy configuration".
.. image:: images/firefox_manual_https.png
Do we want to reuse, for the HTTPS mode, the same configuration as for the HTTP mode?
A new `boolean` type variable
-------------------------------
We have a new variable, named `use_for_https` here:
.. confval:: use_for_https
:type: `boolean`
:default: `true`
This is a setting that enables to reuse the HTTP proxy configuration for HTTPS
Its description in the structure file gives us this:
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_030/firefox/20-manual.yml
:language: yaml
:caption: firefox/20-manual.yml
..
---
manual:
use_for_https:
description: Also use this proxy for HTTPS
type: boolean
default: true

View file

@ -144,7 +144,7 @@ then we need to activate the `manual` family.
And we understand that this activation/deactivation of the `manual` family And we understand that this activation/deactivation of the `manual` family
depends on the value of the `proxy_mode` variable. depends on the value of the `proxy_mode` variable.
In rougail, we can set a property's value depending on the value of another variable. That is, it is conditioned by another variable. In rougail, we can set a property's value **depending on** the value of another variable. That is, it is conditioned by another variable.
Here is how we can achieve this: Here is how we can achieve this:
@ -187,14 +187,13 @@ Here we have the `disabled` property like this:
variable: proxy_mode variable: proxy_mode
when_not: 'Manual proxy configuration' when_not: 'Manual proxy configuration'
It means that the `disabled` property depends ont he `proxy_mode` variable: It means that the `disabled` property **depends on** the value of another variable.
The `variable` parameter allows you to define the name of the target variable on which the `disabled` property depends.
- if `proxy_mode == 'Manual proxy configuration'` disabled is false (that is,
the `manual` family is **enabled**)
- else the `disabled` property is true (that is, the `manual` family is **disabled**)
What does it allow you to do?
- if `proxy_mode` is not `'Manual proxy configuration'` it disables the `manual` family
- if `proxy_mode == 'Manual proxy configuration'` it enables the `manual` family
.. keypoints:: Key points progress .. keypoints:: Key points progress

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View file

@ -42,5 +42,6 @@ At first glance we can see that we have a selection of five configuration option
preliminary preliminary
proxymode proxymode
disabled disabled
boolean
tutorial tutorial