felangel / felangel/mason

feat: input variable as default for subsequent input variables

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

Description

**Description**

While creating a brick that takes multiple inputs, I would like a previously entered input to be usable as a default value for subsequent variable inputs.

Say I'm creating a custom bloc brick that adds a bloc structure to one of my app's pages. Currently I would write something like this:

```yaml
name: my_custom_bloc
description: Generate a new custom Bloc in Dart
version: 0.1.0+1

environment:
mason: ">=0.1.0-dev.32 <0.1.0"

vars:
page:
type: string
description: The name of the page containing the future bloc.
default: login
prompt: What is the page name?
bloc:
type: string
description: The name of the bloc class.
# This input default could be set to what has already been entered for a previous variable
default: login
prompt: What is the bloc name?
```

When executing this brick, I would get something like this:

```shell
mason make my_custom_bloc
? What is the page name? (login) auth
? What is the bloc name? (login) auth
```

which mean if I want to use the same value for both inputs (and that value differs from the default value) I have to enter it two times.

What I would like to do is something like this:

```shell
mason make my_custom_bloc
? What is the page name? (login) auth
? What is the bloc name? (auth) auth # automatically suggested by the brick, based on previous input
```

where the second input default value matches what has been entered by the user for the first input.

I would expect to write a brick definition that looks similar to this:

```yaml
name: my_custom_bloc
description: Generate a new custom Bloc in Dart
version: 0.1.0+1

environment:
mason: ">=0.1.0-dev.32 <0.1.0"

vars:
page:
type: string
description: The name of the page containing the future bloc.
default: login
prompt: What is the page name?
bloc:
type: string
description: The name of the bloc class.
# This input default could be set to what has already been entered for a previous variable
default: {{ page }}
prompt: What is the bloc name?
```

Does that make sense ?

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.