@@ -15,20 +15,20 @@ Cmd :: {
1515 ## ```roc
1616 ## Cmd.exec!("echo", ["hello world"])?
1717 ## ```
18- # exec! : Str, List(Str) => Try({}, [ExecFailed({ command : Str, exit_code : I32 }), FailedToGetExitCode { command : Str, err : IOErr }, ..])
19- # exec! = |program, arguments| {
20- # exit_code =
21- # new(program)
22- # .args(arguments)
23- # .exec_exit_code!()?
18+ exec! : Str , List (Str ) => Try ({}, [ExecFailed ({ command : Str , exit_code : I32 }), FailedToGetExitCode ( { command : Str , err : IOErr }) , ..])
19+ exec! = |program, arguments| {
20+ exit_code =
21+ new(program)
22+ . args (arguments)
23+ . exec_exit_code !()?
2424
25- # if exit_code == 0 {
26- # Ok({})
27- # } else {
28- # command = "${cmd_name } ${arguments.join_with(" ")}"
29- # Err(ExecFailed({ command, exit_code }))
30- # }
31- # }
25+ if exit_code == 0 {
26+ Ok ({})
27+ } else {
28+ command = " ${program } ${arguments.join_with(" " )}"
29+ Err (ExecFailed ({ command, exit_code }))
30+ }
31+ }
3232
3333 ## Execute a Cmd (using the builder pattern).
3434 ## Stdin, stdout, and stderr are inherited from the parent process.
@@ -42,16 +42,16 @@ Cmd :: {
4242 ## .env("RUST_BACKTRACE", "1")
4343 ## .exec_cmd!()?
4444 ## ```
45- # exec_cmd! : Cmd => Try({}, [ExecCmdFailed { command : Str, exit_code : I32 }, FailedToGetExitCode { command : Str, err : IOErr }, ..])
46- # exec_cmd! = |cmd| {
47- # exit_code = exec_exit_code!(cmd)?
48- #
49- # if exit_code == 0 {
50- # Ok({})
51- # } else {
52- # Err(ExecCmdFailed({ command: to_str(cmd), exit_code }))
53- # }
54- # }
45+ exec_cmd! : Cmd => Try ({}, [ExecCmdFailed ( { command : Str , exit_code : I32 }) , FailedToGetExitCode ( { command : Str , err : IOErr }) , ..])
46+ exec_cmd! = |cmd| {
47+ exit_code = exec_exit_code!(cmd)?
48+
49+ if exit_code == 0 {
50+ Ok ({})
51+ } else {
52+ Err (ExecCmdFailed ({ command: to_str(cmd), exit_code }))
53+ }
54+ }
5555
5656 ## Execute command and capture stdout and stderr as UTF-8 strings.
5757 ## Invalid UTF-8 sequences are replaced with the Unicode replacement character.
0 commit comments