gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
16.51k stars 691 forks source link

CLI to run Gleam Hex packages outside of a local Gleam package #2864

Open lpil opened 3 months ago

lpil commented 3 months ago

Similar to npx.

We likely need to know when to recompile any Erlang bytecode as when the VM version changes the bytecode may no longer be valid. manveru on discord suggested this way of getting the Erlang version.

❮ time erl -noinput -boot no_dot_erlang +A0 +sbtu -mode minimal -noshell -eval 'io:format(standard_io, "~s~n", [erlang:system_info(system_version)]),halt()'
Erlang/OTP 25 [erts-13.2.2.6] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [jit:ns]

erl -noinput -boot no_dot_erlang +A0 +sbtu -mode minimal -noshell -eval   0,45s user 0,12s system 453% cpu 0,127 total

What should the CLI be?

samifouad commented 3 months ago

i like this idea. would it be a separate command?

eg. gpx ____ (short for gleam package execution)

or something part of the main binary? eg. gleam x _____

also, a command i've been using to get the erlang version info is:

erl -eval 'io:format("OTP: ~s, ERTS: ~s~n", [erlang:system_info(otp_release), erlang:system_info(version)]), halt().' -noshell

output: OTP: 26, ERTS: 14.2.2

lpil commented 3 months ago

It would be in the same binary. Perhaps something like gleam run --package blah

PgBiel commented 2 months ago

Personally, I think the gleam run command is pretty good for this, since it has a good bit of customizability (target, runtime, arguments) which is sometimes needed when running things. Or, at least, a subcommand for this should inherit gleam run's syntax.

han-tyumi commented 2 months ago

I like the idea of simply using run with an additional option. I was thinking these may be more clear to the intent.

gleam run --hex <package> gleam run --remote <package>

Coming from the JS world - mainly Deno.. Perhaps using a specifier before the package name could be an elegant way to denote that we want to run a non-local package.

gleam run hex:package

lpil commented 2 months ago

gleam run hex:package would be passing hex:package as a command line argument to your program, so that's not an option here.