Zulip Chat Archive

Stream: new members

Topic: cli args


crab (Jan 05 2022 at 15:27):

can you take in command line arguments in lean?

Adam Topaz (Jan 05 2022 at 15:35):

In lean 4, you can do, e.g., the following:

def main (L : List String) : IO Unit :=
for l in L do
  IO.println l

and the command line arguments will be passed in as the list of strings to the main function. I don't know how to do this in lean3.

Adam Topaz (Jan 05 2022 at 15:36):

In fact, I realized now I don't even know how to compile lean3 code into a binary...

Julian Berman (Jan 05 2022 at 15:36):

io.cmdline_args it looks like

Julian Berman (Jan 05 2022 at 15:36):

e.g. https://github.com/leanprover-community/lean/blob/65ad4ffdb3abac75be748554e3cbe990fb1c6500/tests/lean/run/socket_client.lean#L16-L21 (which I just found by github serach)

crab (Jan 05 2022 at 17:00):

Adam Topaz said:

In lean 4, you can do, e.g., the following:

def main (L : List String) : IO Unit :=
for l in L do
  IO.println l

and the command line arguments will be passed in as the list of strings to the main function. I don't know how to do this in lean3.

thank you


Last updated: Dec 20 2023 at 11:08 UTC