pub mod helpers;
pub mod helpers_formal;
pub mod network;
pub mod evaluate;
pub mod compose;
pub mod okf;
pub mod cross_pkc;
pub mod system_ops;
use crate::Commands;
pub fn run_cli(command: Commands, clm_root: &str) -> ! {
match command {
cmd @ (Commands::Daemon { .. }
| Commands::MdnsDiscovery { .. }
| Commands::DiscoveryNode { .. }
| Commands::Discover { .. }
| Commands::ChatGateway { .. }) => {
network::run_network_cli(cmd, clm_root);
std::process::exit(0);
}
cmd @ (Commands::Evaluate { .. }
| Commands::DispatchRuntime { .. }) => {
if let Commands::Evaluate { clm_file: Some(ref f), ref batch, function_handle: None, .. } = cmd {
if batch.is_empty() {
if let Some((exit_code, stdout, stderr)) = helpers_formal::try_evaluate_formal_clm(f, clm_root) {
if !stdout.is_empty() { print!("{}", stdout); }
if !stderr.is_empty() { eprint!("{}", stderr); }
std::process::exit(exit_code);
}
}
}
evaluate::run_evaluate_cli(cmd, clm_root);
std::process::exit(0);
}
cmd @ Commands::ComposeConditions { .. } => {
compose::run_compose_cli(cmd, clm_root);
std::process::exit(0);
}
cmd @ (Commands::OkfMount { .. }
| Commands::OkfUnmount { .. }
| Commands::OkfSync { .. }) => {
okf::run_okf_cli(cmd, clm_root);
std::process::exit(0);
}
cmd @ Commands::CrossPkcDispatch { .. } => {
cross_pkc::run_cross_pkc_cli(cmd, clm_root);
std::process::exit(0);
}
cmd => {
let (exit_code, stdout, stderr) = run_command_logic(cmd, clm_root);
if !stdout.is_empty() {
print!("{}", stdout);
}
if !stderr.is_empty() {
eprint!("{}", stderr);
}
std::process::exit(exit_code);
}
}
}
pub(crate) fn run_command_logic(command: Commands, clm_root: &str) -> (i32, String, String) {
match command {
cmd @ (Commands::Daemon { .. }
| Commands::MdnsDiscovery { .. }
| Commands::DiscoveryNode { .. }
| Commands::Discover { .. }
| Commands::ChatGateway { .. }) => network::run_logic(cmd, clm_root),
Commands::Runtime { action } => helpers_formal::run_runtime_subcommand(action, clm_root),
cmd @ (Commands::Evaluate { .. }
| Commands::DispatchRuntime { .. }
| Commands::ProveTests { .. }
| Commands::Compile { .. }
| Commands::UpgradeEvaluator { .. }
| Commands::RunTest { .. }
| Commands::PetriRunNet { .. }
| Commands::ComposeNets { .. }
| Commands::Classify { .. }
| Commands::DetectDialect { .. }
| Commands::AssessEquivalence { .. }) => evaluate::run_logic(cmd, clm_root),
cmd @ (Commands::ComposeConditions { .. }
| Commands::Substitute { .. }
| Commands::Augment { .. }
| Commands::Hmr { .. }
| Commands::Split { .. }
| Commands::Merge { .. }
| Commands::Tool { .. }
| Commands::Evolve { .. }
| Commands::NormalizeSyntax { .. }
| Commands::FileToMcard { .. }
| Commands::SatoriParse { .. }
| Commands::SatoriFormat { .. }
| Commands::SatoriIngest { .. }
| Commands::SatoriPrompt { .. }) => compose::run_logic(cmd, clm_root),
cmd @ (Commands::OkfMount { .. }
| Commands::OkfUnmount { .. }
| Commands::OkfSync { .. }) => okf::run_logic(cmd, clm_root),
cmd @ (Commands::CrossPkcDispatch { .. }
| Commands::DidGenerate
| Commands::DidRegister { .. }
| Commands::SbtIssue { .. }
| Commands::SbtVerify { .. }
| Commands::AuthConfigMint { .. }
| Commands::AuthConfigList { .. }
| Commands::AuthChallenge { .. }
| Commands::AuthSign { .. }
| Commands::AuthVerify { .. }
| Commands::AuthTokenVerify { .. }
| Commands::IdpRegister { .. }
| Commands::IdpList { .. }
| Commands::AuthOidcExchange { .. }
| Commands::AuthSiweExchange { .. }
| Commands::PaymentRailRegister { .. }
| Commands::PaymentInvoiceCreate { .. }
| Commands::PaymentProcess { .. }
| Commands::PaymentReceiptVerify { .. }) => cross_pkc::run_logic(cmd, clm_root),
cmd @ (Commands::DependencyGraph { .. }
| Commands::CoherenceAudit { .. }
| Commands::Gate { .. }
| Commands::ResolveBinary { .. }
| Commands::MigrateMeta { .. }
| Commands::VcardGate { .. }) => system_ops::run_logic(cmd, clm_root),
cmd => helpers::run_logic(cmd, clm_root),
}
}