felangel / felangel/mason

feat: Nested variables

Ouverte
#637 1 commentaire 8 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Dart
Étoiles
1.1k
Forks
113
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

**Description**

Sometimes when creating a brick, we might want to optionally include some code if the user wishes so. For example, we might have a `include_color` variable which would generate a `Color` class if it is `true`, and nothing otherwise.

This is pretty simple to do, but if the generation of the `Color` class itself depends on a variable that is used nowhere else, it gets ugly. Now we have to prompt for `include_color` *and* the other variable, with some ugly message like `Enter a value for other_value (has no effect if include_color was false): ...`. It'd be better to just be able to skip prompting for `other_value` entirely.

I suggest we allow boolean variable to specify a list of variables that should be prompted for if they are set. This means that a `brick.yml` might look like this:
```yaml
name: ...
...

vars:
my_variable:
type: boolean
description: an option
vars: # New key, only valid for boolean variables
my_other_var: # This nested var has the same structure as vars declared in the top-level vars object
type: string
description: Another variable here
```

In this case, the user would be prompted to choose a value for `my_variable`. If they choose `false`, nothing else happens. If they choose `true`, then they are prompted to enter a value for `my_other_var`.

Of course, vars can also be nested arbitrarily deep (so a nested variable could itself have a nested variable).

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.