-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from HigherOrderCO/feature/sc-499/add-documen…
…tation-on-passing-arguments-to [sc-499] Add documentation on cli arguments
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# CLI arguments | ||
|
||
It's possible to pass arguments to a program executed with `hvml run`: | ||
```sh | ||
hvml run <Path to program> [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 <file> arg1 arg2 arg3`, it becomes: | ||
|
||
main = (λx1 λx2 λx3 (MainBody x1 x2 x3) arg1 arg2 arg3) | ||
``` | ||
|
||
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) | ||
// Can't receive CLI arguments | ||
main = λx λy λz (MainBody x y z) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters