command line enhancements for project creation
add a small tweak for command line project creation: allow user to provide folder name or path.
current behavior
folder and project identifier are the same.
$ bld create
Please enter a number for the project type:
1: base (Java baseline project)
2: app (Java application project)
3: lib (Java library project)
4: rife2 (RIFE2 web application)
2
Please enter a package name (for instance: com.example):
foo.bar
Please enter a project name (for instance: myapp):
baz
Downloading: (... downloads ...)
Downloading finished successfully.
The project was successfully created at '/home/sombriks/Documentos/xpto/baz'.
However, if i decide to go with a project name which is an invalid package identifier:
$ bld create
Please enter a number for the project type:
1: base (Java baseline project)
2: app (Java application project)
3: lib (Java library project)
4: rife2 (RIFE2 web application)
2
Please enter a package name (for instance: com.example):
foo.bar
Please enter a project name (for instance: myapp):
my-awesome-app
ERROR: The project name is invalid.
Current workaround is to create the project and then rename the folder later. But would be nice to get that step solved at project creation already.
Proposed usage
bld creates the directory as usual. if it's an invalid project identifier, spawn an warning and do some cosmetics on the name:
$ bld create
Please enter a number for the project type:
1: base (Java baseline project)
2: app (Java application project)
3: lib (Java library project)
4: rife2 (RIFE2 web application)
2
Please enter a package name (for instance: com.example):
foo.bar
Please enter a project name (for instance: myapp):
my-awesome-app
WARNING: using myawesomeapp as project identifier
Downloading: (... downloads ...)
Downloading finished successfully.
The project was successfully created at '/home/sombriks/Documentos/xpto/my-awesome-app'.
I always have to change the directory name because it never matches the class name. I'd prefer having something like:
$ bld create-app
Please enter a package name (for instance: com.example):
rife.bld.extension
Please enter a project name (for instance: my-app):
bld-kotlin
Please enter the main class name (default: BldKotlinMain):
KotlinCompileOperation
We could use something like the following to validate the main class name:
boolean isValidClassName (String className) {
return SourceVersion.isIdentifier(className) && !SourceVersion.isKeyword(className);
}
@ethauvin I like your suggestion, @sombriks would that work for you?
@ethauvin I like your suggestion, @sombriks would that work for you?
Indeed it's very ergonomic!
for all-in one commands, would this align what you expect:
bld create-rife2 com.example my-app TheAppItIs
I'm wondering if this is becoming too many unnamed arguments and if we have to start naming then?
for all-in one commands, would this align what you expect:
bld create-rife2 com.example my-app TheAppItIs
As well as:
bld create-rife2 com.example my-app
To remain backward compatible.
I'm wondering if this is becoming too many unnamed arguments and if we have to start naming then?
I don't think so… And if we did, I would expect something like:
bld create --type rife2 --project com.example my-app --class TheAppItIs
I started looking into this and the new argument should not be the main classname imho. bld uses a project classname for various other classnames:
projectClassName_ = StringUtils.capitalize(project_.name());
projectBuildName_ = projectBuildClassName(projectClassName_);
projectMainName_ = projectMainClassName(projectClassName_);
projectMainUberName_ = projectMainUberClassName(projectClassName_);
projectTestName_ = projectTestClassName(projectClassName_);
So the third argument should be that project classname for the best consistency. However, I'm not sure what the best way to name this is.