-
Notifications
You must be signed in to change notification settings - Fork 28
Closed
Description
For shell script, for example ./examples/example.sh in this repo, both
usage bash --help ./examples/example.shandusage bash ./examples/example.sh --help
print help of the script.
However for non-shell scripts (with shebang #!/usr/bin/env -S usage exec <cmd>), for example the ./examples/test-usage-double-slash.js in this repo, none of
usage exec node --help ./examples/test-usage-double-slash.jsusage exec node ./examples/test-usage-double-slash.js --help
print help of the script. They both print help for usage exec.
$ cat <<EOF >./greet
#!/usr/bin/env -S usage exec node
//USAGE flag "-f --force" help="Overwrite existing <file>"
//USAGE flag "-u --user <user>" help="User to run as"
//USAGE arg "<file>" help="The file to write" default="file.txt"
const { usage_user, usage_force, usage_file } = process.env;
console.log("Force overwrite:", usage_force);
console.log("User:", usage_user);
console.log("Writing to file:", usage_file);
EOF
$ chmod +x greet
$ ./greet -fu Jimmy
Force overwrite: true
User: Jimmy
Writing to file: file.txt
$ ./greet --help
Execute a script, parsing args and exposing them as environment variables
Usage: usage exec <COMMAND> <BIN> [ARGS]...
Arguments:
<COMMAND> command to execute after parsing usage spec
<BIN> path to script to execute
[ARGS]... arguments to pass to script
Options:
-h, --help Print help
$ usage exec node --help ./greet
# help for "usage exec"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels