Open tonytangio opened 3 years ago
I dug a bit further to understand if this was explicitly intended and found that the commit which introduced this validation referenced the specification for a shard name.
This explains which convention/specification that the validation is trying to maintain, but I still believe that the validation should not be done at this point. To reiterate my original points, we want to allow for an arbitrary level of capitalisation for the generated module/spec names (of course, assuming the best about users' awareness of convention here), and enforce all-lowercase at the point when it's actually needed (naming the project root dir according to shard name specification).
Yes, the reason for those name restrictions is to enforce compatibility with the shard specification to avoid any surprises with unexpected project names.
However, I agree that an automatic transformation from PascalCased name could be a good enhancement. Currently it works the other way around in View#module_name
which transforms snake_case to PascalCase for the module name.
This direction is lossy though, because there's no way to accurately transform to PascalCased acronyms.
That being said, it's also easy to just change the spelling to your liking manually after running crystal init
.
Discussion
What aspect of the language would you like to see improved?
Currently the crystal compiler's
crystal init
command does not accept any UPPERCASE characters within the name, raising an error during its name validation.I believe that this validation step should be removed. If required, the generated project name could still be explicitly outputted as all-lowercase.
What are the reasons?
While I can understand if this is to promote an all-lowercase project directory name convention (not that I could find if this is actually a convention as per the conventions section of the crystal-lang reference), I believe that not allowing a project name with UPPERCASE:
Include practical examples to illustrate your points.
crystal init app foobar
module Foobar
crystal init app FooBar
module FooBar
crystal init app acmebar
module Acmebar
crystal init app ACMEBar
module ACMEBar
Optionally add one (or more) proposals to improve the current situation.
Remove the line of lowercase validation.
Update the crystal-lang reference conventions to specify what project structures should look like.
Optionally, explicitly output project root directory name as all lowercase if still desired.