[proposal] Implement environment variables support for options
Hi,
Would a contribution adding support for environment variables be accepted for options such as -c or --nginx?
The use case is using resty in a shebang as such:
#!/usr/bin/env resty -c 1024
This will only work on BSD-like platforms, and not Linux. We can mitigate this if we implement:
$ export RESTY_CLI_CONNECTION_COUNT=1024
$ export RESTY_CLI_NGINX=/path/to/nginx
Does this make sense? Which options would we like to see an environment variable for? I am thinking all but -e and the include directives (http, main, and -I), but let me know if not. Would you accept a contribution for RESTY_CLI_CONNECTION_COUNT only?
Thanks!
@thibaultcha All look good to me.
+1 on this feature. Currently we use some wrapper scripts to workaround this on Linux. Environment variables seems to be a cleaner solution.
Does:
#!/usr/bin/env -S resty -c 1024
work with Linux these days?
@bungle Yes, it works. for example
test.lua
#!/usr/bin/env -S resty -c 1024
print("hello")
chmod +x t.lua ./t.lua