felangel / felangel/mason

feat: Add conditional question support with `when` clause in brick.yaml

Open
#1,576 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.1k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

## **Hey there! 👋**

So I've been working with mason bricks and noticed something that could really improve the user experience. Right now, when you create a brick with multiple options (like different auth methods), users get bombarded with irrelevant questions.

## **The Problem**

Imagine this scenario - you're creating a Flutter app and you select "no_auth" as your authentication method, but then mason still asks you:
- "Do you want to enable Google Sign-In with Firebase?"
- "Do you want to enable Apple Sign-In with Firebase?"

Like... what? 😅 That doesn't make any sense! If I chose no auth, why am I getting Firebase questions?

## **What I'm Proposing**

Add a simple `when` clause to brick.yaml variables so we can conditionally show questions based on previous answers. Something like this:

```yaml
vars:
auth_method:
type: enum
values: [firebase, custom_jwt, no_auth]
default: firebase
prompt: Which authentication method do you want to use?

firebase_google:
type: boolean
default: true
prompt: Do you want to enable Google Sign-In with Firebase?
when: auth_method == firebase # Only show if firebase is selected

firebase_apple:
type: boolean
default: true
prompt: Do you want to enable Apple Sign-In with Firebase?
when: auth_method == firebase # Only show if firebase is selected
```

## **Why This Matters**

**Current Flow (Confusing):**

? Which authentication method do you want to use? no_auth
? Do you want to enable Google Sign-In with Firebase? (Y/n) 🤔
? Do you want to enable Apple Sign-In with Firebase? (Y/n) ��
*

**With `when` clause (Clean):**

## **What Needs to Be Done**

### **Parser Stuff:**
- [ ] Make brick.yaml understand `when` conditions
- [ ] Add validation for condition syntax
- [ ] Support basic operators like `==`, `!=`, `in`, `not in`

## **Real-World Example**

I'm building a Flutter Riverpod starter brick, and when someone selects "no_auth", they still get Firebase questions. It's super confusing! This feature would fix that instantly.

---

**TL;DR:** Add `when` clauses to brick.yaml so questions only show when they're relevant. Makes mason way more user-friendly! 🚀

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.