mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Add Stderr.line to cli-platform
This commit is contained in:
parent
d0656bf793
commit
762fa75511
3 changed files with 12 additions and 6 deletions
|
@ -3,8 +3,8 @@ hosted Effect
|
||||||
imports [InternalHttp.{ Request, Response }]
|
imports [InternalHttp.{ Request, Response }]
|
||||||
generates Effect with [after, map, always, forever, loop]
|
generates Effect with [after, map, always, forever, loop]
|
||||||
|
|
||||||
putLine : Str -> Effect {}
|
stdoutLine : Str -> Effect {}
|
||||||
|
stderrLine : Str -> Effect {}
|
||||||
getLine : Effect Str
|
stdinLine : Effect Str
|
||||||
|
|
||||||
sendRequest : Box Request -> Effect Response
|
sendRequest : Box Request -> Effect Response
|
||||||
|
|
|
@ -4,5 +4,5 @@ interface Stdout
|
||||||
|
|
||||||
line : Str -> Task {} * [Write [Stdout]*]*
|
line : Str -> Task {} * [Write [Stdout]*]*
|
||||||
line = \str ->
|
line = \str ->
|
||||||
Effect.map (Effect.putLine str) (\_ -> Ok {})
|
Effect.map (Effect.stdoutLine str) (\_ -> Ok {})
|
||||||
|> InternalTask.fromEffect
|
|> InternalTask.fromEffect
|
||||||
|
|
|
@ -113,7 +113,7 @@ unsafe fn call_the_closure(closure_data_ptr: *const u8) -> i64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn roc_fx_getLine() -> RocStr {
|
pub extern "C" fn roc_fx_stdinLine() -> RocStr {
|
||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
|
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
|
@ -123,11 +123,17 @@ pub extern "C" fn roc_fx_getLine() -> RocStr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn roc_fx_putLine(line: &RocStr) {
|
pub extern "C" fn roc_fx_stdoutLine(line: &RocStr) {
|
||||||
let string = line.as_str();
|
let string = line.as_str();
|
||||||
println!("{}", string);
|
println!("{}", string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn roc_fx_stderrLine(line: &RocStr) {
|
||||||
|
let string = line.as_str();
|
||||||
|
eprintln!("{}", string);
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn roc_fx_sendRequest(roc_request: &glue::Request) -> glue::Response {
|
pub extern "C" fn roc_fx_sendRequest(roc_request: &glue::Request) -> glue::Response {
|
||||||
let mut builder = reqwest::blocking::ClientBuilder::new();
|
let mut builder = reqwest::blocking::ClientBuilder::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue