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

Enable building as a standalone escript #48

Open
erszcz opened this issue Feb 22, 2022 · 2 comments
Open

Enable building as a standalone escript #48

erszcz opened this issue Feb 22, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@erszcz
Copy link
Member

erszcz commented Feb 22, 2022

In some cases it's more convenient to use a standalone CLI tool than add a dependency to a project. To enable this, we can make Gradient a standalone escript. Thanks @chouzar for the idea!

ex_doc is configured for building as an escript and it's relatively easy to set up. The real lifting is in providing a sensible CLI entry point accepting arguments and options, but with some care it might be able to use a lot of the Mix task entry point's code that we already have.

This should also allow for installing Gradient from Hex once we make it a package, but let's keep that for another ticket (#49):

mix escript.install hex gradient
@erszcz erszcz added enhancement New feature or request good first issue Good for newcomers labels Feb 22, 2022
@Fl4m3Ph03n1x
Copy link
Contributor

How would you run this as an escript?

./gradualizer my_folder

Something like this? Or do you have more options in mind?

@erszcz
Copy link
Member Author

erszcz commented Apr 21, 2022

I would try to reuse as much code as possible with the current Mix task (which, in turn, mimics the gradualizer CLI). This means we mostly need a way to figure out code paths outside a Mix environment - I think the rest is mostly taken care of by @Premwoik in the Mix task.

Please note, though, that reusing this code would likely mean refactoring it not to use Mix, to accept extra code path options, and then calling from Mix with the Mix-provided project-specific code paths as options.

Code paths would likely only require one CLI option to be passed to the script: -pa, the same as Gradualizer or the Elixir and Erlang compilers use.

I think the script should accept directories as well as single files. It's handy to be able to type check just one file when bug hunting (either in the checked code or in the type checker itself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants