From 09492296f99795ffa9cb9c582247b6d51f805022 Mon Sep 17 00:00:00 2001 From: imaqtkatt Date: Fri, 8 Mar 2024 11:19:03 -0300 Subject: [PATCH] Update cli arguments doc --- docs/cli-arguments.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/cli-arguments.md b/docs/cli-arguments.md index b592de5d1..e786b0b12 100644 --- a/docs/cli-arguments.md +++ b/docs/cli-arguments.md @@ -1,25 +1,33 @@ # CLI arguments It's possible to pass arguments to a program executed with `hvml run`: + ```sh hvml run [Arguments in expression form]... ``` + It accepts any expression that would also be valid inside an hvm-lang function. Arguments are passed to programs by applying them to the entrypoint function: + ```js main x1 x2 x3 = (MainBody x1 x2 x3) -// Calling with `hvml run arg1 arg2 arg3`, it becomes: +// Calling with `hvml run arg1 arg2 arg3 argN`, it becomes: -main = (λx1 λx2 λx3 (MainBody x1 x2 x3) arg1 arg2 arg3) +main = (λx1 λx2 λx3 (MainBody x1 x2 x3) arg1 arg2 arg3 argN) ``` -The entrypoint function must receive exactly the number of arguments specified in the left-hand side of its definition. -``` -// Must pass exactly 3 arguments when running -main x y z = (MainBody x y z) +There are no restrictions on the number of arguments passed to the program. + +```rust +// Can receive 2 CLI arguments +main x y = (+ x y) // Can't receive CLI arguments -main = λx λy λz (MainBody x y z) -``` \ No newline at end of file +main = λx λy (+ x y) + +// Calling with just one argument +hvml run 5 +λa (+ a 5) +```