-
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
feat: GooeyCLI - replacement utility scripting system based on PicoCLI. #4065
Conversation
config/groovy/GooeyCLI.groovy
Outdated
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Grab the Groovy extensions for PicoCLI - in IntelliJ Alt-ENTER on a `@Grab` to register contents for syntax highlighting |
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.
Ideally lines 4-12 here would disappear if I can use the code from inside the Gradle Wrapper instead
I tried to run the
I moved everything into a package and moved the groovy stuff to another folder.
any way we can get this to work with idea @keturn would have a clue? |
Thanks @pollend ! I've wondered if setting this up as its own sourceSet in Gradle would add anything, but IntelliJ already prompts to configure a Groovy SDK. Maybe if it was Gradled it would also auto-fetch the Not super high priority to find out just yet. Happy just to know it is working for somebody else (after a few tweaks) |
Still a proof of concept, with a limited amount of old functionality converted to showcase the new approach. Relies on a groovyw tweak, renames the scripts, and lets PicoCLI worry about all the CLI structuring
… being deleted rather than replaced
* Moves it to a maybe more sensible place in the gradle directory where the wrapper lives, this seems kinda related * Standardizes the source path so we don't need to explicitly configure it * Drops the Groovy dependency (in Gradle) down to match what's currently in the Gradle Wrapper (although it would still get fetched and used separately for any sort of GooeyCLI *build* process)
Okay, bunch more updates in, including @pollend's initial Gradle setup taken a few steps further. Commands like There was a point when the Sneaking in bits of colored text but this is still a draft with a ton of extra logging just to make it easier to check on this. More to come, just sleepy 💤 Edit: Still not actually copying in template files or a |
description = "Utility system for interacting with a Terasology developer workspace") | ||
class GooeyCLI extends BaseCommandType { | ||
static void main(String[] args) { | ||
AnsiConsole.systemInstall() // enable colors on Windows - TODO: Test on not-so-Windows systems, should those not run this? |
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.
On not windows systems - no matter.
colors works with and without this line
Closing this to clean up, will recreate in the future if the coding spirits will it 👍 |
Still a proof of concept, with a limited amount of old functionality converted to showcase the new approach. Relies on a
groovyw
tweak (MovingBlocks/groovy-wrapper#5), renames the scripts (gw
is < 1/3rd ofgroovyw
! Think of the savings!), and lets PicoCLI worry about all the CLI structuring. Also experimenting with Terasology/Index#7Contains
Overhaul of our utility scripting. PicoCLI takes away all the awkwardness surrounding argument parsing and such, plus automatically generates usage text, even at every level, a la
kubectl
,docker
,git
, etc.Key part is defining commands and options inside small classes using PicoCLI. A command class can define a link to sub-command classes, which in turn can have their own and so on (
gw
->module
->get
..). From anywhere you can mix-in other classes containing simple definitions for options, so you only need to define a given option (like--origin
) in one place then just mix it in wherever needed. If something isn't relevant for a given combination just don't link it. Easy!util.groovy
is no more, the weird loading of files as text to then turn them into Groovy scripts dynamically is gone, and you can write way cleaner, well, everything.help
/-h
/--help
command is available at every level, detailing everything automatically. Extra examples can easily be added beyond the auto-generated stuffDiagram!
The green stuff can actually be run, everything else is supporting (some sub-commands require additional sub-commands - you can run
gw module
but will get an error about that being meaningless on its own). Diagram doesn't cover all use cases and not everything listed is done yet.How to test
gw
commands in the root of your workspaceThat's it, really! Everything else should just work, no extra steps needed. Not a lot is actually functional yet
help
command in various places. Or nothing at all and see what happensgw module get ModuleName
should work normally, you can add-o
/--origin
to vary where to get modules from. The oldgradle.properties
global override for different GitHub locations should also work, if set (example:alternativeGithubHome=Nanoware
)recurse
and other stuff isn't in yetgw init
says some things, including colored output!-o
flag in different places, using different commandsgw module refresh
should do thebuild.gradle
update to all modules, demonstrates a sub-command defined specifically within an item type - sort of like a private command to that parent, rather than write it in its own file, when it won't make sense anywhere elseOutstanding before merging
@Grab
s@Grab
a built jar from there. In most cases users don't really need the scripts themselves, and I'm sure we could come up with a way to sub in source when you want to edit it, like with other items. Benefit: Use the exact same setup for both Terasology and DestSol (and more?), limit the amount of code in the engine repo, possibly version things better?Future goals
While not a goal with this PR I'm hoping to build more advanced functionality on top of it, partly via my day job where I'm trying to do something similar in a different use case (enterprise CI/CD / app dev)
fork
command that'll create a fork on GitHub of a target itempr
command that'll create a PR automagicallybulk
commands to handle large-scale modifications, such as an engine change needing minor tweaks in a dozen or two modules (prep branches, bulk commit, push to GitHub, make / merge PRs if desired, possibly add markup somewhere to tell Jenkins to test them all together)wiki
items or evengh-pages
items if we end up using those