std-mumu 0.2.2

Standard input/output tools for MuMu/Lava
Documentation
# std-mum

Standard Input/Output Plugin for [MuMu/Lava](https://lava.nu11.uk)


[![crates.io](https://img.shields.io/crates/v/mumu-std.svg)](https://crates.io/crates/v/mumu-std)
[#License: MIT OR Apache-2.0](https://img.shields.io/crates/l/mumu-std)](LICENSE)


____

## Overview

*mumu-std** provides classic and stream-oriented input/output functions for the [MuMu/Lava](https://lava.nu11.uk) scripting language.  
\nIt delivers essential tools like printing, logging, blocking input, and interactive input streams-**all as a plugin** loaded at runtime.

- Minimal, portable, and follows the Lava plugin architecture.
- Makes I/O explicit and modular not built-in magic.

----

## Features

- `std:put(value)` \t- Print without newline (`print`)
- `std:log(value)`  - Print with newline (`println_`)
- `std:input(prompt)`  - Prompt the user and read a line (blocking)
- `std:input_iter()` - Stream user input lines as an InkIterator (for use in pipelines or functional flows)


----

## Installation

### 1. **Build and Install**

Clone and build this crate as you would any MuMu/Lava plugin:

```sh
git clone https://gitlab.com/tofo/mumu-std.git
cd mumu-std
make
sudo make install
```

This copies `libmumustd.so` to `/usr/local/lib/`.

### 2. **Enable in Lava/MuMu**

In your Lava script or REPL, load the plugin:

```
load_library("std")
```


----

## Usage Examples

****Basic Printing and Input****

`lava
extend("std")

std:put("Hello, ")
std:log("world!") # Outputs: Hello, world!\n

name = std:input("Enter your name: ")
std:log("Welcome, " + name)
```

----

### Stream (Iterator) Input Example

Use `std:input_iter()` to create an iterator over lines from the user (or from piped input):

`lava
extend("std")

inp = std:input_iter()

std:log("Type lines (Ctrl-D to end):")

while (line = inp()) != "_END_"
\t std:log("> " + line)
```
*[Note: The iterator yields one line per call, as a string. Returns "_END_" (or errors) when no more data. ]*

----

## API

### std:put(value)

- Prints `value` to stdout without a newline.
- Returns the value.
 - Example:  
` std:put("Count: ")`

### std:log(value)
- Prints `value` to stdout with a newline.
 - Returns the value.
 - Example:  
` std:log("Done!") `

### std:input(prompt)
- Prints an optional `prompt` string, waits for a line of user input, and returns it as a string.
- **Blocks** until the user enters a line.
- Example:  
` line = std:input("Next command> ") `

### std:input_iter()
- Returns an **InkIterator** that yields each line of user input as a string.
- Non-blocking per call (but blocks when waiting for new input).
- Suitable for functional pipelines, `while` loops, and partial application.

---

## Philosophy

- **No I/O is magic.** All input/output functions are plugins, not core language.
- **Both blocking and stream styles supported.**
- **Naming**:  
  - `std:put`/std:log` follow Rust/Python/JS idioms.
  - `std:input_iter` matches Lava's stream/InkIterator conventions.

---

## License

Dual-licensed under **MIT** and **Apache-2.0** (your choice).  
See [LICENSE](LICENSE) for full details.

----

## Support & Contributions

- [GitLab project]https://gitlab.com/tofo/mumu-std
- PRs and issues welcome!
- Maintained by [Tom Fotheringham]https://lava.nu11.uk and contributors.

---

## Version Compatibility

- Works with MuMu/Lava ` >= 0.11.0`
- Rust edition: 2021

## Changelog

- **0.1.0**: Initial release – `put`, `log`, `input`, `input_iter` implemented.

---

## Acknowledgments

This project is part of the [Lava](https://lava.nu11.uk) ecosystem. 
Big thanks to everyone in the open source and MuMu/Lava community.

----