std-mumu

Crates.iostd-mumu
lib.rsstd-mumu
version0.1.1
created_at2025-08-12 13:04:47.220882+00
updated_at2025-08-12 13:04:47.220882+00
descriptionStandard input/output tools for MuMu/Lava
homepage
repositoryhttps://gitlab.com/tofo/mumu-std
max_upload_size
id1791972
size42,527
(justifiedmumu)

documentation

README

std-mum

Standard Input/Output Plugin for MuMu/Lava

crates.io #License: MIT OR Apache-2.0](LICENSE)


Overview

mumu-std* provides classic and stream-oriented input/output functions for the MuMu/Lava 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:

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 for full details.


Support & Contributions


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 ecosystem. Big thanks to everyone in the open source and MuMu/Lava community.


Commit count: 0

cargo fmt