jimtcl 0.2.0

Embed Jim Tcl in Rust.
Documentation
//! Command-line shells.

use std::path::PathBuf;

use clap::Parser;

use crate::{Interp, JimResult};

/// Clap CLI for implementing jimsh-like shells.
#[derive(Parser, Debug)]
#[command(version)]
pub struct Jimsh {
    /// Tcl script to exeecute.
    script: Option<PathBuf>,
}

impl Jimsh {
    /// Run the command line in the specified interpreter.  Returns the Jim
    /// exit code on success.
    pub fn run(&self, interp: &Interp) -> JimResult<i32> {
        let result = if let Some(path) = &self.script {
            interp.eval_file(path)
        } else {
            interp.interactive_prompt()
        };
        interp.resolve_exit(result)
    }
}