Skip to content

Let compiled binaries pass --help through to IO.args #934

Description

@noah-emp

Behavior

A Bend-compiled native binary treats --help as a runtime flag. Before main runs, the runtime prints its own usage (--threads, --gpu, --gpu-build, --help, --) and exits. The program never sees --help in IO.args().

The same reserved handling applies to --threads, --gpu, and --gpu-build. Words after -- are passed through unchanged, including --help.

Minimal example

# demo.bend
import Base

def main() -> IO(Unit):
  do IO<Unit>:
    +av : List<&1, String> <- IO.args()
    match av:
      case Con{h, _t}:
        IO.print(h)
      case Nil{}:
        IO.print("(none)")

Build and run:

bend demo.bend -o bin/demo
bin/demo --help          # runtime usage; process exits; demo does not run
bin/demo -- --help       # prints: --help
bin/demo hello           # prints: hello

Request

Prefer one of:

  1. Pass --help through to IO.args() (move runtime help to something like --bend-help), or
  2. Keep runtime --help only when the binary has no program arguments and/or when explicitly requested, and otherwise forward --help to the program.

Goal: a compiled CLI can implement its own --help the way users expect, without requiring help as a subcommand or -- --help.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions