felangel / felangel/mason

feat: Nested variables

未关闭
#637 1 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Dart
星标
1.1k
派生
113
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。