[−][src]Function molt_shell::script
pub fn script(interp: &mut Interp, args: &[String])
Executes a script from a set of command line arguments.
args[0]
is presumed to be the name of a Molt script file, with any subsequent
arguments being arguments to pass to the script. The script will be be executed in
the context of the given interpreter.
Molt Variables
The calling information will be passed to the interpreter in the form of Molt variables:
- The Molt variable
arg0
will be set to thearg0
value. - The Molt variable
argv
will be set to a Molt list containing the remainder of theargv
array.
See molt::interp
for details on how to configure and
add commands to a Molt interpreter.
Example
use molt::Interp; use std::env; // FIRST, get the command line arguments. let args: Vec<String> = env::args().collect(); // NEXT, create and initialize the interpreter. let mut interp = Interp::new(); // NOTE: commands can be added to the interpreter here. // NEXT, evaluate the file, if any. if args.len() > 1 { molt_shell::script(&mut interp, &args[1..]); } else { eprintln!("Usage: myshell *filename.tcl"); }