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

Ability to set enums in config #62

Closed
SHaaD94 opened this issue May 16, 2020 · 4 comments
Closed

Ability to set enums in config #62

SHaaD94 opened this issue May 16, 2020 · 4 comments

Comments

@SHaaD94
Copy link

SHaaD94 commented May 16, 2020

It would be cool to have an ability to set a field which might have only limited set of values for example, let's say fruitType can be only apple, banana or pineapple.
In the config it could look like this:

app.fruitType = "string E ["apple", "banana", "pineapple"]"

After it, sealed trait with three classes could be generated:

trait FruitType 
object FruitType {
   object Apple extends FruitType
   object Banana extends FruitType
   object Pineapple extends FruitType
}
@carueda
Copy link
Owner

carueda commented May 17, 2020

Adding enums would be great, thanks.

At the spec level, maybe something combined with or similar to @define (#54):

#@define enum
FruitType = [apple, banana, pineapple]

# then, somewhere for the actual use/reference:

foo: {
  fruit: FruitType,
  ...
}

@johanneshiry
Copy link
Collaborator

hi @SHaaD94 - are you interested in actively working to provide this feature? I handed in #64 which would make a huge benefit in several of our projects and as @carueda suggested I might make sense to talke your proposal and #64 together ...

@carueda
Copy link
Owner

carueda commented Jun 30, 2020

@SHaaD94 / @johanneshiry : fyi, i've done some progress on this, but will have to postpone completion for a little while (the java generation seems pretty complete, but not yet the scala one, at least for enum references at the root of the given config). I realize that enhancements like this and #64 are not as "straightforward" as one would like them to be given that the code has become rather complex; I myself have to spend some time catching up with the structure of things, etc. (I wish I had more time to proceed with a general revision.) Thanks again for your suggestions and contributions, really appreciated.

@carueda carueda closed this as completed in a09b5c3 Mar 4, 2021
@carueda
Copy link
Owner

carueda commented Mar 4, 2021

Implemented in 0.9.983 - https://github.com/carueda/tscfg#enum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants