modcli/
lib.rs

1pub mod loader;
2pub mod config;
3pub mod input;
4pub mod output;
5pub mod command;
6pub mod parser;
7use crate::loader::CommandRegistry;
8pub use crate::command::Command as CliCustom;
9
10#[cfg(feature = "internal-commands")]
11pub mod commands;
12
13#[cfg(feature = "custom-commands")]
14pub mod custom;
15
16
17/// Represents a CLI application
18pub struct ModCli {
19    pub registry: CommandRegistry,
20}
21
22impl ModCli {
23
24    pub fn new() -> Self {
25        Self {
26            registry: CommandRegistry::new(),
27        }
28    }
29
30
31    pub fn run(&self, args: Vec<String>) {
32        if args.is_empty() {
33            eprintln!("No command provided.");
34            return;
35        }
36
37        let cmd = &args[0];
38        let cmd_args = &args[1..];
39        self.registry.execute(cmd, cmd_args);
40    }
41}
42
43/// Returns the version of the ModCLI framework (from modcli/Cargo.toml)
44pub fn modcli_version() -> &'static str {
45    env!("CARGO_PKG_VERSION")
46}