7 releases

✓ Uses Rust 2018 edition

0.3.1 May 11, 2020
0.3.0 Apr 10, 2020
0.2.2 Jan 18, 2020
0.2.0 Dec 27, 2019
0.1.1 Sep 21, 2019

#6 in #script

Download history 1/week @ 2020-01-24 8/week @ 2020-01-31 11/week @ 2020-02-07 25/week @ 2020-02-14 21/week @ 2020-02-21 15/week @ 2020-02-28 11/week @ 2020-03-06 5/week @ 2020-03-13 27/week @ 2020-03-20 9/week @ 2020-03-27 1/week @ 2020-04-03 53/week @ 2020-04-10 16/week @ 2020-04-17 12/week @ 2020-04-24 3/week @ 2020-05-01 17/week @ 2020-05-08

68 downloads per month
Used in 2 crates

BSD-3-Clause

410KB
7K SLoC

molt -- An Embeddable Tcl Interpreter for Rust

New in Molt 0.3.1

See the Annotated Change Log in the Molt Book for the complete list of new features by version.

Description

Molt is an embeddable TCL interpreter for Rust. Applications can define new TCL commands in Rust and execute TCL scripts and strings. For example,

use molt::Interp;
let mut interp = Interp::new();

let four = interp.eval("expr {2 + 2}")?;
assert_eq!(four.as_int(), 4);

A new command is defined like so:

use molt::check_args;
use molt::MoltResult;
use molt::Value;
use molt::Interp;
use molt::molt_ok;

/// # square *x*
///
/// Computes the square of a value
pub fn cmd_square(_interp: &mut Interp, _: ContextID, argv: &[Value]) -> MoltResult {
    // Correct number of arguments?
    check_args(1, argv, 2, 2, "x")?;

    // Get x, if it's an integer
    let x = argv[1].as_int()?;

    // Return the result.
    molt_ok!(x * x)
}

and installed like so:

use molt::Interp;
let mut interp = Interp::new();
interp.add_command("square", cmd_square);

let num = interp.eval("square 5")?;
assert_eq!(num.as_int(), 25);

Values are represented by the Value type, which can be converted to and from any type consistent with the value's string representation: integers, floats, lists, and any type that defines the MoltAny trait.

Molt is still a work in progress. The basic TCL language is in place, but many TCL commands remain to be implemented. See the Molt Book for details.

The molt-sample repo contains a sample Molt extension, including a shell application and a library create, both of which define new Molt commands.

See my blog for news, The Molt Book for details, and the GitHub Repo for issue tracking, etc.

Dependencies