#error "'stdio' can only be included in the 'wasi' or 'js' runtime."
}
-stdin: io.Stream;
+stdio_stream: io.Stream;
auto_flush_stdio := true
// This shouldn't need to be here, but because ^stdin_vtable is not a compile-time
// known value (even through it should be).
- stdin.vtable = ^stdin_vtable;
+ stdio_stream.vtable = ^stdio_vtable;
}
^stdio.print_stream |> io.stream_flush();
}
-#local stdin_vtable := io.Stream_Vtable.{
+#local stdio_vtable := io.Stream_Vtable.{
read = (_: ^io.Stream, buffer: [] u8) -> (io.Error, u32) {
__flush_stdio();
bytes_read := runtime.__read_from_input(buffer);
if bytes_read <= 0 do return .EOF, 0;
return .None, buf[0];
+ },
+
+ write = (_: ^io.Stream, buffer: [] u8) -> (io.Error, u32) {
+ return io.stream_write(^stdio.print_stream, buffer);
+ },
+
+ write_byte = (_: ^io.Stream, byte: u8) -> io.Error {
+ return io.stream_write_byte(^stdio.print_stream, byte);
+ },
+
+ flush = (_: ^io.Stream) -> io.Error {
+ __flush_stdio();
+ return .None;
}
}
}
@TODO // Validation for these fields.
- r := io.reader_make(^stdin);
+ r := io.reader_make(^stdio_stream);
read_field("Package name: ", ^config.metadata.name);
read_field("Package description: ", ^config.metadata.description);
read_field("Package url: ", ^config.metadata.url);
return;
}
- r := io.reader_make(^stdin);
+ r := io.reader_make(^stdio_stream);
while true {
printf("Is this a m[a]jor, m[i]nor, or [p]atch release? or [c]ancel? (a/i/p/c) ");