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

Generating multiple files from a list type #1153

Open
Thithip opened this issue Nov 16, 2023 · 0 comments
Open

Generating multiple files from a list type #1153

Thithip opened this issue Nov 16, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Thithip
Copy link

Thithip commented Nov 16, 2023

Hi!

I have this question about generating a list of files, but after search on docs and other issues, I think this is not implemented. Or maybe I do it in the wrong way... 🤔
I create this bug as a bug, but feel free to label it correctly if I miss something.

Description
I want to generate a list of files, from a list param in the brick.yaml file. This will allow the user of the brick to generate multiple files with the same logic inside.

For example, we want to generate multiple models from a brick called generate_data_models, with the following brick.yaml file:

name: generate_data_models
description: Creates a new data models
version: 0.1.0+1

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

vars:
  data_folder_name:
    type: string
    description: Name of the data folder to put the model files inside.
    prompt: What is the data folder name?
  models: 
    type: list
    description: List of models, used to create basic model class files.
    prompt: What are the models names to create (separated by comma)?
    separator: ","

And the following brick tree:

.
├── CHANGELOG.md
├── LICENSE
├── README.md
├── __brick__
│   └── lib
│       └── data
│           └── {{data_folder_name.snakeCase()}}
│               ├── data
│               │   └── data.dart
│               ├── models
│               │   ├── models.dart
│               │   └── {{#models}}{{..snakeCase()}}.dart{{
│               │       └── models}}
│               └── {{data_folder_name.snakeCase()}}.dart
└── brick.yaml

When I generate the code from this brick, this will create the following tree (inspired by the Weather tuturial):

lib/data
└── open_meteo_api
    ├── data
    │   └── data.dart
    ├── models
    │   ├── location.dartweather.dart
    │   └── models.dart
    └── open_meteo_api.dart

The expected output will be two separated files generated for location & weather:

lib/data
└── open_meteo_api
    ├── data
    │   └── data.dart
    ├── models
    │   ├── location.dart
    │   ├── models.dart
    │   └── weather.dart
    └── open_meteo_api.dart

Plus, inside each file we want to access to the current model to generate the relevant code class code for this model.

@Thithip Thithip added the bug Something isn't working label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant