Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enum conditionals #1385

Open
1 task
lishaduck opened this issue Aug 3, 2024 · 2 comments
Open
1 task

feat: enum conditionals #1385

lishaduck opened this issue Aug 3, 2024 · 2 comments
Labels
enhancement candidate Candidate for enhancement but additional research is needed

Comments

@lishaduck
Copy link

Description

I'm trying to create an app template that can be optionally compatible with Serverpod & Dart Frog.
I'd originally created with without server support, then added Serverpod support via a boolean. Now, I'd like to additionaly add optional support for Dart Frog, but it shouldn't be possible to create an app supporting both Serverpod and Dart Frog. Therefore, I'd like to convert it my boolean to an enum.
However, there does not appear to be (at least documented) support for switch-cases in mason.

Requirements

  • Allow switch-casing (or equivalent) over enums in mason

Additional Context

n/a?

@Luckey-Elijah
Copy link
Contributor

Mason's brick.yaml supports enum types
Here is an example from the favorite color example:

name: favorite_color
description: A new brick created with the Mason CLI.

version: 0.1.0+1

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

vars:
  color:
    type: enum
    description: Your favorite color
    default: green
    prompt: What is your favorite color?
    values:
      - red
      - green
      - blue

@lishaduck
Copy link
Author

Mason's brick.yaml supports enum types.

Yes, the issue is that you can't case over them. I'd like to define

server:
  type: enum
  values:
    - none
    - serverpod
    - dart_frog

and then do the following in my templates:

{{server.none}}
{{/server.none}}

// or

{{server}}
  {{.none}}{{/.none}}
  {{.dart_frog}}{{/.dart_frog}}
{{/server}}

@felangel felangel added the enhancement candidate Candidate for enhancement but additional research is needed label Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement candidate Candidate for enhancement but additional research is needed
Projects
None yet
Development

No branches or pull requests

3 participants