Amber: [CLI] - Batch generation from yaml file

Created on 26 Apr 2018  路  4Comments  路  Source: amberframework/amber

It would be nice to have a feature in the CLI whereby you can enter a command to parse a yaml file and generate multiple models, classes and views from the yaml file.

Example command:

amber batch mysite.yml

... that will process a file like:

Model:
  Post:
    - "title:string"
    - "body:text"
    - "user:reference"
  User:
    - "name:string"
    - "password:string"
  Comment:
    - "title:string"
    - "body:text"
    - "user:reference"

It will use the CLI generator to create all of the Models, Views, and Controllers in a single step.

An alternative syntax may be something like:

Post:
  Model:
      - "title:string"
      - "body:text"
      - "user:reference"
  Controller:
    {goes here}
  View:
    {goes here}
User:
  Model:
    - "name:string"
    - "password:string"
  Controller:
    {goes here}
  View:
    {goes here}
Comment:
  Model:
    - "title:string"
    - "body:text"
    - "user:reference"
  Controller:
    {goes here}
  View:
    {goes here}

Use case

I was looking at the RealWorld project and started mocking up a model based on API specs using Yaml as it allows me to visualize how the application needs to be modeled. Since YAML files generally have structure, it was visually helpful to see the application layout before generating.

But I thought it might also be useful for:

  • If you're trying to translate customer/stakeholder requirements into a structured form, you write a template to feed to the Amber generator
  • You are porting an application to Amber and you want to translate the basic underpinnings of the application to a project skeleton
cli

Most helpful comment

@sumwatt IMO this should most likely live on its own shard. I do not believe this should be embedded in the framework

All 4 comments

_Rough_ exmple of what the a batch generator might look like. I purloined most of the code from the Generator class and made some modifications. I looked at YAML mapping but wasn't quite sure how to map unknown keys so I just cast each to the appropriate type. The branch code should work for model/controller/view/scaffold

@sumwatt IMO this should most likely live on its own shard. I do not believe this should be embedded in the framework

@sumwatt Yeah, I apologize for opening this issue in your repo, I thought this would be an interesting tool for amber cli, although this can live perfectly in his own shard :sweat_smile:

Closing this issue since this we agree that this should live in its own shard

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faustinoaq picture faustinoaq  路  6Comments

faustinoaq picture faustinoaq  路  5Comments

yorci picture yorci  路  6Comments

faustinoaq picture faustinoaq  路  7Comments

aarongodin picture aarongodin  路  7Comments