Non-interactive Code Execution
Closed this issue · 2 comments
It would be nice to have a flag which allows providing one-liner code as an argument. The REPL exists, however it requires an interactive shell, meaning it cannot be used in automated scripts.
Python has a -c
switch which achieves this functionality. In the future, this could be used alongside -g
as per #137, which would allow for some super short one-liners.
For non-interactive use cases you can already do this by using stdin (https://lune-org.github.io/docs/getting-started/3-command-line-usage#advanced-usage) and this avoids any issues with escaping or parsing strings. For interactive use cases you're better off making an alias for printf "$1" | lune run -
or similar.
The main problem for the REPL is that it's not possible to have any sort of persistent config or environment, you have to type out all the globals you need every single time you enter it. This is why an alternative approach like a "REPL config" file is also mentioned in that issue
Apologies, totally forgot about stdin piping!