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 define default values for properties defined multiple times #5

Closed
pun-ky opened this issue May 23, 2018 · 2 comments
Closed
Assignees
Milestone

Comments

@pun-ky
Copy link
Contributor

pun-ky commented May 23, 2018

There is no way to elegantly define default value for e.g projectGroup. Consider new DSL:

fork {
    config {
        cloneFiles()
        moveFiles([
                "/com/company/x/example": "/{{projectGroup|substitute('.', '/')}}/{{projectName}}",
                "/example": "/{{projectName}}"
        ])
        replaceContents([
                "com.company.x.example": "{{projectGroup}}.{{projectName}}",
                'com.company.x': "{{projectGroup}}",
                "Example": "{{projectLabel}}",
                "example": "{{projectName}}",
        ])
        defineProperties([
                property "projectGroup", "com.company.x"
                property "projectLabel", "Example",
                property "projectName", "example" 

                /* below mostly expected :)
                property "projectName",  { 
                    defaultValue = "example"
                    validator = { !it.value('projectGroup').contains(it.value)) } 
                }
                */
               property "libVersion", { // that property will be used in some template file, not in above sections directly
                    defaultValue = "1.0.0"
                    radio ['1.0.0', '2.00', '3.0.0''] // GUI control type 'radio' instead of default 'textfield'
                    required()
                }
        ])
    }
}

@pun-ky pun-ky changed the title Ability to define default values for vars defined multiple times Ability to define default values for properties defined multiple times May 23, 2018
@pun-ky pun-ky self-assigned this May 23, 2018
@pun-ky pun-ky added this to the 1.1.0 milestone May 23, 2018
@pun-ky
Copy link
Contributor Author

pun-ky commented Jun 5, 2018

consider implementing more nice GUI controls when providing capability to define type of placeholder, validator, default value and possible options (e.g for radio)

@pun-ky
Copy link
Contributor Author

pun-ky commented Aug 17, 2018

alternative syntax / DSL

fork {
    config /* 'default', */ { 
        cloneFiles()
        moveFiles([
                "/com/company/app/example": "/{{projectGroup|substitute('.', '/')}}/{{projectName}}",
                "/example": "/{{projectName}}"
        ])
        replaceContents([
                "com.company.app.example": "{{projectGroup}}.{{projectName}}",
                'com.company.app': "{{projectGroup}}",
                "Example": "{{projectLabel}}",
                "example": "{{projectName}}",
        ])
        defineProperties([
                "projectGroup": {
                    defaultValue = "com.company"
                    required()
                },
                "projectName": {
                    defaultValue = "example"
                    validator = { 
                        if (value('projectGroup').contains(value)) {
                            error("Project name cannot contain project group.")
                        }}
                    } 
                }
        ])
    }
    inPlaceConfig 'setup', {
        copyTemplateFile("gradle.properties")
    }
}

@pun-ky pun-ky modified the milestones: 1.1.0, 3.0.0 Jan 9, 2019
pun-ky added a commit that referenced this issue Jan 14, 2019
@pun-ky pun-ky closed this as completed Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant