mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Add /.args
feature to Redbean/Lua/SQLite/Python/QuickJS
You now have some ability to truly make an executable yours, by adding a `.args` file to the root of the zip structure. If this is specified, then you'll be overriding the default CLI args. This will be a great feature for folks who want to distribute their own apps, using the interpreter executable, but have the executable appears to be just your app rather than being the interpreter.
This commit is contained in:
parent
0f6251f4d2
commit
4499f98e76
19 changed files with 421 additions and 19 deletions
|
@ -452,6 +452,41 @@ SPECIAL PATHS
|
|||
If you enable HTTPS client verification then redbean will check
|
||||
that HTTPS clients (a) have a certificate and (b) it was signed.
|
||||
|
||||
/.args
|
||||
Specifies default command-line arguments.
|
||||
|
||||
There's one argument per line. Trailing newline is ignored. If
|
||||
the special argument `...` is *not* encountered, then the
|
||||
replacement will only happen if *no* CLI args are specified.
|
||||
If the special argument `...` *is* encountered, then it'll be
|
||||
replaced with whatever CLI args were specified by the user.
|
||||
|
||||
For example, you might want to use redbean.com in interpreter
|
||||
mode, where your script file is inside the zip. Then, if your
|
||||
redbean is run, what you want is to have the default behavior
|
||||
be running your script. In that case, you might:
|
||||
|
||||
$ cat <<'EOF' >.args
|
||||
-i
|
||||
/zip/hello.lua
|
||||
EOF
|
||||
|
||||
$ cat <<'EOF' >hello.lua
|
||||
print("hello world")
|
||||
EOF
|
||||
|
||||
$ zip redbean.com .args hello.lua
|
||||
$ ./redbean.com
|
||||
hello world
|
||||
|
||||
Please note that if you ran:
|
||||
|
||||
$ ./redbean.com -vv
|
||||
|
||||
Then the default mode of redbean will kick back in. To prevent
|
||||
that from happening, simply add the magic arg `...` to the end
|
||||
of your `.args` file.
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
HOOKS
|
||||
|
|
|
@ -66,6 +66,7 @@ TOOL_NET_DIRECTDEPS = \
|
|||
THIRD_PARTY_REGEX \
|
||||
THIRD_PARTY_SQLITE3 \
|
||||
THIRD_PARTY_ZLIB \
|
||||
TOOL_ARGS \
|
||||
TOOL_BUILD_LIB \
|
||||
TOOL_DECODE_LIB
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
#include "third_party/mbedtls/x509_crt.h"
|
||||
#include "third_party/regex/regex.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
#include "tool/args/args.h"
|
||||
#include "tool/build/lib/case.h"
|
||||
#include "tool/build/lib/psk.h"
|
||||
#include "tool/net/lfuncs.h"
|
||||
|
@ -3745,8 +3746,7 @@ static int LuaFetch(lua_State *L) {
|
|||
// skip them to avoid duplicates;
|
||||
// also allow unknown headers
|
||||
if ((hdridx = GetHttpHeader(key, keylen)) == -1 ||
|
||||
hdridx != kHttpContentLength &&
|
||||
hdridx != kHttpConnection) {
|
||||
hdridx != kHttpContentLength && hdridx != kHttpConnection) {
|
||||
if (hdridx == kHttpUserAgent) {
|
||||
agenthdr = hdr;
|
||||
} else if (hdridx == kHttpHost) {
|
||||
|
@ -7036,6 +7036,7 @@ void RedBean(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
LoadZipArgs(&argc, &argv);
|
||||
if (!IsTiny()) {
|
||||
ShowCrashReports();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue