1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
mod argc_value;
mod build;
mod command;
mod compgen;
mod mangen;
mod matcher;
mod param;
mod parser;
pub mod utils;

use anyhow::Result;
pub use argc_value::ArgcValue;
pub use build::build;
pub use command::CommandValue;
pub use compgen::{compgen, Shell};
pub use mangen::mangen;
pub use param::{ChoiceValue, DefaultValue, EnvValue, FlagOptionValue, PositionalValue};

pub fn eval(
    script_content: &str,
    args: &[String],
    script_path: Option<&str>,
    term_width: Option<usize>,
) -> Result<Vec<ArgcValue>> {
    let mut cmd = command::Command::new(script_content, &args[0])?;
    cmd.eval(args, script_path, term_width)
}

pub fn export(source: &str, root_name: &str) -> Result<CommandValue> {
    let cmd = command::Command::new(source, root_name)?;
    Ok(cmd.export())
}