felangel / felangel/mason

feat: Nested variables

Aperta
#637 1 commento 8 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
1.1k
Fork
113
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

**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).

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.