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

Artifacts and template inputs shouldn't be white-spaces #178

Open
AbdelRahmaneB opened this issue Nov 7, 2016 · 3 comments
Open

Artifacts and template inputs shouldn't be white-spaces #178

AbdelRahmaneB opened this issue Nov 7, 2016 · 3 comments

Comments

@AbdelRahmaneB
Copy link
Contributor

White-spaces as artifacts and template inputs's names cause many exceptions.
Should loop until a valid name is provided

@AbdelRahmaneB
Copy link
Contributor Author

@aalmiray About :

props.project_group = ask("Define value for 'group' [org.example]: ", "org.example", "group")
props.project_name = ask("Define value for 'artifactId' [" + props.project_name + "]: ", props.project_name, "artifactId")
props.project_version = ask("Define value for 'version' [0.1.0-SNAPSHOT]: ", "0.1.0-SNAPSHOT", "version")
props.griffon_version = ask("Define value for 'griffonVersion' [2.9.0-SNAPSHOT]: ", "2.9.0-SNAPSHOT", "griffonVersion")
props.project_package = ask("Define value for 'package' [" + props.project_group + "]: ", props.project_group, "package")
props.project_class_name = ask("Define value for 'className' [" + props.project_class_name + "]: ", props.project_class_name, "className").capitalize()

And

if (!props.project_package) {
    props.project_package = parentParams.package
    props.project_package = ask("Define value for 'package' [" + props.project_package + "]: ", props.project_package, "package")?.trim()
}

Should we loop over the asks until a valid name is provided ?
Should we create a Utils class for names validation ?
and use it like :

while ( !NameUtils.isValidClassName( props.project_class_name = ask("Define value for 'className' [" + project_class_name + "]: ", project_class_name, "className").capitalize())) {}

or someting like :

//getValidClassName will loop until a valid className is given
props.project_class_name = NameUtils.getValidClassName("Define value for 'className' [" + props.project_class_name + "]: ", props.project_class_name, "className").capitalize()

@aalmiray
Copy link
Member

aalmiray commented Nov 8, 2016

I thought so too. The ask() method only cares if a value is given but doesn't check for its semantic validity (such as the string should not contain empty whitespace chars). A NameUtils class sounds like a good idea at first but the problem is that it has to be included as part of the binary release of each template. An alternative is to publish a tiny JAR into a common repository (such as jcenter) and pull it in via Groovy's @Grab AST transformation. In other words, it requires more moving parts that what it seems at first.

@AbdelRahmaneB
Copy link
Contributor Author

AbdelRahmaneB commented Nov 8, 2016

Should we go for overloading lazybones's ask() method to take , for example, as extra parameter a varargs of predefined regexs ? (if it suits them)
Or as a first solution we go for a NameUtils class ?

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

2 participants