-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chore[facade]: use picocli for processing command line options #4157
Conversation
I ended up moving everything currently in Terasology (the class with the static main method) to a new class (TerasologyCommand), but it looks like I didn't have to do that. I could I have left that main as static but switched everything else to non-static. Those aren't two useful classes, it just moved stuff around and left a one-line static method in the other class, so I think I'll shift it back so it's a smaller change overall. [that's a recap from discord, adding it here as a comment as I haven't got to actually do it yet.] |
|
||
|
||
private static void printUsageAndExit() { | ||
// TODO: Add all this stuff back in to the help text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is then added via the picocli library, isn't it? I don't think we need to copy word-by-word, but just make sure that users can figure out what options/flags are available.
*/ | ||
|
||
@CommandLine.Command(name = "terasology") | ||
public class TerasologyCommand implements Callable<Integer> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Callabale
move this to a different thread? Will this cause even more issues with porting to LWJGL 3 and MacOS (see #3969 )?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it runs it in another thread. I think picocli just uses Callable as an interface that's easy to define for use with its .execute(it)
method, so it can run it, handle exceptions, and get a process return code at the end. But it'll be a good thing to double-check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed this. currentThread()
returns the same value inside the call
method as it does in the static main
.
chore[facade]: remove extraneous TerasologyCommand class
fa143cb
to
a096796
Compare
It's working in IntelliJ IDEA but the build-with-command-line-gradle fails. 😞
changing the picocli dependency type to Not sure what the deal is. Is it related to the picolci-codegen or annotation processing or something? |
It's something in the difference between the |
I think we are going to have to gitignore this file though 😞
Its values are obtained from the gradle configuration. See https://youtrack.jetbrains.com/issue/IDEA-251986
Oh heck. I just realized that if we change the way command-line options are spelled, Launcher needs to know. We could add aliases for the old spellings. It wouldn't be difficult. Thing is, I like the idea of following the POSIX conventions for these, and in that convention prefixing options with a single dash means you're using the short-form single-letter options. That's a potential source of confusion I'd like to avoid. I'd prefer to make this explicitly-breaking-change instead, get it over with. But then what does Launcher do? Is it willing to break compatibility with previous releases just as quickly, or do we need to teach it to use old-style options if the version number is below a cutoff point? |
At the moment the whole engine is going through a large split and change so I wouldn't be too worried about breaking API changes if it makes things work better. I also don't want to have stuff be bagged down by older changes for the sake of consistency since I don't think we have any obligations to keep things consistent. for backwards compatibility just use a version check so the launcher can run older copies of the game. |
The blocker to getting this merged is the And if we're working on the For that, we could use some documentation on our requirements for those tasks.
I think the part where questions come up is around modules. Currently // Dependencies: natives + all modules & the PC facade itself (which will trigger the engine)
dependsOn(":extractNatives")
dependsOn(":moduleClasses")
dependsOn("classes") Where And // Classpath: PC itself, engine classes, engine dependencies.
// Not modules or natives since the engine finds those.
classpath(sourceSets["main"].output.classesDirs)
classpath(sourceSets["main"].output.resourcesDir)
classpath(project(":engine").sourceSets["main"].output.classesDirs)
classpath(project(":engine").sourceSets["main"].output.resourcesDir)
classpath(project(":engine").configurations.runtimeClasspath) from reading that, I expect:
[continued…] |
Follow-up questions to earlier: We habitually tell people to run
There's a category of module development workflow requirements that I'd like to have spelled out, not only for this but for any time we make changes to the gradle + IntelliJ build process. Things like:
|
Gradle jar game - it is old behaviour (before my changes to build.gradle) it is seems was related with build dir or reflections.cache. dont remember Gestalt-module works fine with classes and jars(idk which priorities) If you change source - then rebuilding only changef module and it's dependents. Reflections - builds at compile time and used by gestalt-module. If reflections.cache not found - then it gathering at runtime. Better: gather reflection when classes(or compileJava) task done and uptodate it when classes uptodate. Reloading: Debugging with gradle works fine. |
classesDo we keep the the reloadingOn asset reloading: There's this gestalt demo video showing changing textures. Is it sufficient to just write to their source locations, without having I went looking for docs on asset reloading. I found a brief note about it here: https://github.com/MovingBlocks/gestalt/wiki/Gestalt-Asset-Core-Quick-Start#reload-assets-changed-on-disk the invocation to reload on tick is in TerasologyEngine.tick reflections
That “better” option is one of those things where I expect we could do it for just gradle, but I'm worried about getting consistent behavior when mixed with IntelliJ IDEA's compilation process. ScopeA lot of these notes are only very loosely related to this picocli PR, but they are related in that we're specifying the things that need to keep working when we tinker with these JavaExec tasks and their classpaths. I'll want to organize this information and put it someplace. A page on MovingBlocks/Terasology/wiki I guess? |
ClassesWe cannot use gradles build dir definition (build/classes/main) and not copy resources in classes dir because gestalt-module/gestalt-assets use only one dir from source sets. ReflectionsI hope we can drop reflections and use Annotation Processing, when gestalt DI will done. Then idea and gradle processes will be consistent ScopeTerasology - everytime code research :D Yeah, plz do it! |
then how did that asset-reloading demo work? was the editor saving to the classes directory? or was there a auto-refreshing copy-resources-to-classes task running in the background? maybe it's worth pinging @immortius for info about that demo. |
Copying resources in classes build directory. Gestalt-module can load only one directory as source module. Normal gradle build directories include separate direcories for resources and source sets. |
I still haven't had time to dig into this, although I did just bump into the
|
Ah, that might well be true about the renaming. I (re)introduced the
In what sense? It might have been overlooked among all the comments posted to this issue, but note here that the question that started all that discussion is that the If you're able to describe what
I am against keeping gremlins in source code. You can make a module for gremlins in-game if you want. 😉 As for superstitions, please document them here or in their own issues as appropriate. Then we can do some mythbusters on 'em. 🚫 👻 |
The options have their own documentation.
With that, we can remove the old printUsageAndExit text. Its contents is covered by `--help` and docs/Playing.md.
@skaldarnar, have you started a Launcher branch for this somewhere? |
I've tried to collect the notes we made here about what we expect from build results and classpaths and whatnot on https://github.com/MovingBlocks/Terasology/wiki/Supported-Development-Workflows |
# Conflicts: # facades/PC/build.gradle.kts
That was a potentially messy merge for PC/build.gradle.kts but I think it ended up okay 🤞 |
# Conflicts: # build-logic/src/main/kotlin/org/terasology/gradology/exec.kt # facades/PC/build.gradle.kts # facades/PC/src/main/java/org/terasology/engine/Terasology.java
I did not forget about this ... I swear! Made a note to update the launcher sometime in the not-so-far future. |
# Conflicts: # .idea/misc.xml # facades/PC/src/main/java/org/terasology/engine/Terasology.java
There's been a new picocli release in the meantime. One thing that might be of interest is picocli using |
.idea/misc.xml
Outdated
@@ -1,15 +1,12 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="EntryPointsManager"> | |||
<list size="5"> | |||
<item index="0" class="java.lang.String" itemvalue="org.terasology.entitySystem.event.ReceiveEvent" /> | |||
<item index="1" class="java.lang.String" itemvalue="org.terasology.entitySystem.systems.RegisterSystem" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is RegisterSystem
not needed (anymore)? Is the class considered used in any case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was re-checking these at some point and removing the class-level annotation didn't result in any inspection warning popping up. 🤷
* feat: update command line options for Terasology to use POSIX-style syntax for MovingBlocks/Terasology#4157 * refactor(GameStarter): put platform-specific launch parameters here * fix(VersionHistory): picocli begins with 5.2.0-SNAPSHOT
Launcher supports this now, but I added a new bug in the process. So this is waiting on MovingBlocks/TerasologyLauncher#651 in order for Launcher to be releasable. |
Cleans up the path for the common `--homedir=.` case.
This PR switches PC facade's handling of command-line options to use picocli.
The hope is that it improves input validation, provides better feedback to users, and makes it easier to implement new command-line options.
How to test
test out all the command line options!
Outstanding before merging
--homedir --no-crash-report
isn't a problem (it was using '--no-crash-report` as the value of homedir!)-