argc/
lib.rs

1mod argc_value;
2#[cfg(feature = "build")]
3mod build;
4mod command;
5#[cfg(feature = "compgen")]
6mod compgen;
7#[cfg(feature = "completions")]
8mod completions;
9#[cfg(feature = "mangen")]
10mod mangen;
11#[cfg(any(feature = "eval", feature = "compgen"))]
12mod matcher;
13mod param;
14mod parser;
15mod runtime;
16#[cfg(any(feature = "compgen", feature = "completions"))]
17mod shell;
18pub mod utils;
19
20use anyhow::Result;
21pub use argc_value::ArgcValue;
22#[cfg(feature = "build")]
23pub use build::build;
24#[cfg(feature = "export")]
25pub use command::CommandValue;
26#[cfg(feature = "compgen")]
27pub use compgen::{compgen, compgen_kind, CompKind, COMPGEN_KIND_SYMBOL};
28#[cfg(feature = "completions")]
29pub use completions::generate_completions;
30#[cfg(feature = "mangen")]
31pub use mangen::mangen;
32pub use param::{ChoiceValue, DefaultValue};
33#[cfg(feature = "export")]
34pub use param::{EnvValue, FlagOptionValue, PositionalValue};
35#[cfg(feature = "native-runtime")]
36pub use runtime::navite::NativeRuntime;
37#[cfg(any(feature = "eval", feature = "compgen"))]
38pub use runtime::Runtime;
39#[cfg(any(feature = "compgen", feature = "completions"))]
40pub use shell::Shell;
41
42#[cfg(feature = "eval")]
43pub fn eval<T: Runtime>(
44    runtime: T,
45    script_content: &str,
46    args: &[String],
47    script_path: Option<&str>,
48    wrap_width: Option<usize>,
49) -> Result<Vec<ArgcValue>> {
50    let mut cmd = command::Command::new(script_content, &args[0])?;
51    cmd.eval(runtime, args, script_path, wrap_width)
52}
53
54#[cfg(feature = "export")]
55pub fn export(source: &str, root_name: &str) -> Result<CommandValue> {
56    let cmd = command::Command::new(source, root_name)?;
57    Ok(cmd.export())
58}