Skip to content

Compiled binaries pass --help to IO.args (#934) - #988

Open
YidaWeng wants to merge 2 commits into
bendlang:mainfrom
YidaWeng:fix/934-help-passthrough
Open

YidaWeng wants to merge 2 commits into
bendlang:mainfrom
YidaWeng:fix/934-help-passthrough

Conversation

@YidaWeng

Copy link
Copy Markdown

Summary

  • A compiled C or JS binary treated --help as a runtime flag and never ran main, so a Bend CLI could not implement its own help without -- --help (Let compiled binaries pass --help through to IO.args #934).
  • Runtime help is now --bend-help. --help (and any other non-runtime flag) reaches IO.args() on both lanes.
  • Guide and tests/io/args.bend note the reserved options.

Test plan

  • demo --help prints --help (C and JS); demo --bend-help prints runtime usage and exits 0
  • demo / demo hello still print (none) / hello
  • tests/io/args.bend — interp + C print 0
  • bun gates/repo.ts — PASS 46 / 46
  • Cluster gates/test.ts (no minis here)

Made with Cursor

@nicolas-abril

Copy link
Copy Markdown
Collaborator

I feel like we should have a better solution to not clash with the application's flags, --gpu is also somwhat likely (of course not nearly as much as --bend-help)

@nicolas-abril

Copy link
Copy Markdown
Collaborator

Thank you, the rename is right and we reproduced #934 on both lanes: on main a compiled binary eats --help, on this branch it reaches IO.args and --bend-help prints the usage.

One correction before it can merge. The new sentence in guide/GUIDE.md and the header of tests/io/args.bend say the runtime keeps --threads, --gpu, --gpu-build and --bend-help. That is only true of the C binary: the JS runtime's cli() skips --threads and --gpu alone, so bun x.js --gpu-build hands --gpu-build to the program (args.bend prints 1 under bun, before and after this PR). Please either word the list as what every lane keeps, or keep the old wording ("less the runtime's own options") and name only --bend-help as the new one. With that, we merge.

Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

… own

The guide claimed the runtime keeps --threads, --gpu, --gpu-build and
--bend-help, which holds for the C binary only: the JS cli() skips
--threads and --gpu alone and hands --gpu-build to the program, before
and after bendlang#934. The guide says "less the runtime's own options" again
and names --bend-help as the new one; args.bend spells out each lane.
@YidaWeng

Copy link
Copy Markdown
Author

Fixed in 0414ed9: the guide goes back to "less the runtime's own options (a -- ends them)" and names --bend-help as the new one; tests/io/args.bend now spells out each lane — the C binary keeps --threads, --gpu, --gpu-build and --bend-help, the JS lane only --threads, --gpu and --bend-help.

Checked on both lanes with a build of tests/io/args.bend:

C   --help        -> 1      JS  --help        -> 1
C   --threads 4   -> 0      JS  --threads 4   -> 0
C   --gpu on      -> 0      JS  --gpu on      -> 0
C   --gpu-build   -> 1      JS  --gpu-build   -> 1   (unchanged, pre-existing)
C   --bend-help   -> usage  JS  --bend-help   -> usage

bun gates/repo.ts: PASS 46 / 46.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants