felangel / felangel/mason

feat: Nested variables

Offen
#637 1 Kommentar 8 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
1.1k
Forks
113
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.