Is your feature request related to a problem? Please describe.
In my projects, I automate a lot of things, and being able to invoke xmake with a custom Lua script is incredibly useful, since it has a LOT of interesting features.
However, having those scripts as static files makes it more difficult to customize them (requires CLI arguments or environment variables) or to work in situations of single-file applications (single executable, bundled JavaScript/Python/etc. source file, etc.)
There may be other cases where being able to specify scripts in a more dynamic way would be useful.
Describe the solution you'd like
Be able to specify the Lua script content as stdin. Maybe something like:
$script = '...' # this would be the content of the script
$script | xmake lua - # it's not uncommon to use the dash to specify stdin
# or
$script | xmake lua --from-stdin # more explicit
Describe alternatives you've considered
In the consumer project, generate temporary files, in a safe location, to hold the scripts until they’ve been executed by xmake. Don’t forget to delete the files at the end. This is not very hard, but cumbersome. If the feature requested here is implemented, it could even be the solution chosen internally.
Otherwise, use xmake lua -c $script, but it has a couple of cons:
- when using a Lua file, I have to define a
main function so that xmake won't print the implicitly exported table to stdout; very important when the goal is to use xmake Lua scripts to get back information. But with xmake lua -c, it apparently expects the code NOT to have a main function, otherwise nothing happens (it won't grab it and execute it). That makes me think that -c is for simple use cases. Using stdin instead should match the behavior of the existing feature based on Lua files.
- operating systems or shells may impose a limit on the length of the command line, potentially making it impossible to use big scripts in this scenario. Also, command line arguments — at least on Windows — must be escaped (encoded) and then decoded back in the application (here xmake), which is unfortunate overhead
Additional context
- xmake version:
v3.0.6+HEAD.9fdcf69f6
Is your feature request related to a problem? Please describe.
In my projects, I automate a lot of things, and being able to invoke xmake with a custom Lua script is incredibly useful, since it has a LOT of interesting features.
However, having those scripts as static files makes it more difficult to customize them (requires CLI arguments or environment variables) or to work in situations of single-file applications (single executable, bundled JavaScript/Python/etc. source file, etc.)
There may be other cases where being able to specify scripts in a more dynamic way would be useful.
Describe the solution you'd like
Be able to specify the Lua script content as stdin. Maybe something like:
Describe alternatives you've considered
In the consumer project, generate temporary files, in a safe location, to hold the scripts until they’ve been executed by xmake. Don’t forget to delete the files at the end. This is not very hard, but cumbersome. If the feature requested here is implemented, it could even be the solution chosen internally.
Otherwise, use
xmake lua -c $script, but it has a couple of cons:mainfunction so that xmake won't print the implicitly exported table to stdout; very important when the goal is to use xmake Lua scripts to get back information. But withxmake lua -c, it apparently expects the code NOT to have a main function, otherwise nothing happens (it won't grab it and execute it). That makes me think that-cis for simple use cases. Using stdin instead should match the behavior of the existing feature based on Lua files.Additional context
v3.0.6+HEAD.9fdcf69f6