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

feat: add Quarkus CLI commands #734

Merged
merged 2 commits into from
Oct 19, 2023
Merged

feat: add Quarkus CLI commands #734

merged 2 commits into from
Oct 19, 2023

Conversation

metacosm
Copy link
Member

@metacosm metacosm commented Oct 3, 2023

  • chore: initial work on CLI plugin
  • wip: first commands layout
  • feat: first implementation of API creation command

@metacosm metacosm self-assigned this Oct 3, 2023
@metacosm metacosm requested a review from csviri October 3, 2023 17:30
Copy link
Contributor

@csviri csviri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@metacosm metacosm marked this pull request as ready for review October 6, 2023 16:52
@metacosm metacosm requested review from iocanel and mkouba October 6, 2023 16:53
.forEach(path -> {
try {
final var templateAsString = java.nio.file.Files.readString(path);
final var templateInstance = Qute.fmt(templateAsString)
Copy link

@mkouba mkouba Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mentioned, this is not ideal in the sense that the template content is parsed every time the Qute#fmt() method is called. If you need to render the template multiple times then either use Qute.enableCache() or Qute.engine().parse(...) together with Qute.engine().putTemplate() and Qute.engine().getTemplate()...

Copy link
Member Author

@metacosm metacosm Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get it to work in that context, though… where all the templates are retrieved from the jar and processed the same way. If you have a better way to do, I'll gladly consider it :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'm saying is: if you only render the template once, then Qute.fmt(templateAsString) is OK. If multiple times, then either use Qute.enableCache() - this enables cache for Qute.fmt() by default (templateAsString will be parsed once); or use something like:

// This should be called once
Engine engine = Qute.engine();
engine.putTemplate("myTemplate", engine.parse(templateAsString));
...
// And then to render a template:
Qute.engine().getTemplate("myTemplate").render();

Copy link
Member Author

@metacosm metacosm Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think I was missing the putTemplate part, I thought that I could call getTemplate directly and that wasn't working. Thanks! That said, since these things won't probably be run very often, I'm not sure it matters but I might still make the change (it might help when called from the dev console, maybe?). Then again, you could make a point that if it's not going to be called often, caching a template might actually be worse because then you commit memory to something that will only be used infrequently and possibly only once.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it really depends on the use case 🤷 .

@metacosm metacosm merged commit 392847f into main Oct 19, 2023
5 checks passed
@metacosm metacosm deleted the commands branch October 19, 2023 08:54
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

Successfully merging this pull request may close these issues.

3 participants