felangel / felangel/mason

feat: Nested variables

Open
#637 1 comment 8 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.1k
Forks
113
PR merge metrics
No merged PRs in 30d

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.