pharo-project / pharo-launcher

Lets you manage your pharo images and download new ones
https://pharo-project.github.io/pharo-launcher/
MIT License
109 stars 46 forks source link

Implement better initialization of Pharo launcher model for CLI #565

Closed Bajger closed 1 year ago

Bajger commented 2 years ago

Describe the request Currently, new instance of PharoLauncherModel is created every time the accessor launcherModel is invoked. This could be several times during program execution. PharoLauncherModel should be initialized just once, during image startup and command activation.

Expected behavior Instead of using ClapContext we should use PhLCliClapContext, that uses proper accessors for launcher model (that are already initialized).

Expected development cost It seems that ClapContext is activated in the ClapCommandLineHandler>>activate. Probably we should use something like own PhLCliCommandLineHandler>>activate that would have 'launcher' id (of command) and activate PhLCliClapContext instance. As an consequence, command line usage would not need clap as a first command, but only launcher command. Refactoring of PhLCliCommand would be needed, since this command already uses launcher id (so that launcher is used just in cmd line handler activation).

Bajger commented 1 year ago

Closing issue, it was resolved by: https://github.com/pharo-project/pharo-launcher/commit/2a7ae66f9239a148571d7c1e2a7191b7d348c090#diff-1a6049d3220a5b2319d7d16f035361bb3ec7f52b284455e7e9769f6b2ba76e6eR333 Command will initialize model from context lazily just once.

For command line handler activation (that will have launcher as implicit command) we can have another issue, if needed.