FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
basic-cli/examples/args.roc at main · kili-ilo/basic-cli · GitHub
kili-ilo
/
basic-cli
Public
forked from
roc-lang/basic-cli
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
basic-cli
/
examples
/
args.roc
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (15 loc) · 656 Bytes
Breadcrumbs
basic-cli
/
examples
/
args.roc
Copy path
File metadata and controls
21 lines (15 loc) · 656 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
app
[main!] {
pf: platform
"
../platform/main.roc
"
,
}
# To run this example: check the README.md in this folder
import
pf.
Stdout
import
pf.
Arg
exposing
[
Arg
]
main
! :
List
Arg
=
>
Result
{}
_
main
! = |raw_args|
args =
List
.
map
(
raw_args
,
Arg
.
display
)
# get the second argument, the first is the executable's path
when
List
.
get
(
args
,
1
)
|>
Result
.
map_err
(|_|
ZeroArgsGiven
)
is
Err
(
ZeroArgsGiven
) ->
Err
(
Exit
(
1
,
"
Error ZeroArgsGiven:
\n\t
I expected one argument, but I got none.
\n\t
Run the app like this: `roc main.roc -- input.txt`
"
))
Ok
(first_arg) ->
Stdout
.
line
!("
received
argument: ${first_arg}
"
)
Back
|
FazBrowse Home
|
New Git URL