use crate::cli::{DemoProtocol, OutputFormat, QualityCheckType, QualityGateOutputFormat};
use crate::stateless_server::StatelessTemplateServer;
use anyhow::Result;
use std::path::PathBuf;
use std::sync::Arc;
#[allow(clippy::too_many_arguments)]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub async fn handle_demo(
server: Arc<StatelessTemplateServer>,
path: Option<PathBuf>,
url: Option<String>,
repo: Option<String>,
format: OutputFormat,
protocol: DemoProtocol,
show_api: bool,
no_browser: bool,
port: Option<u16>,
cli: bool,
target_nodes: usize,
centrality_threshold: f64,
merge_threshold: usize,
debug: bool,
debug_output: Option<PathBuf>,
skip_vendor: bool,
max_line_length: Option<usize>,
) -> Result<()> {
let demo_protocol = if cli {
crate::demo::Protocol::Cli
} else {
match protocol {
DemoProtocol::Cli => crate::demo::Protocol::Cli,
DemoProtocol::Http => crate::demo::Protocol::Http,
DemoProtocol::Mcp => crate::demo::Protocol::Mcp,
#[cfg(feature = "tui")]
DemoProtocol::Tui => crate::demo::Protocol::Tui,
DemoProtocol::All => crate::demo::Protocol::All,
}
};
let web_mode = !cli;
let demo_args = crate::demo::DemoArgs {
path,
url,
repo,
format,
protocol: demo_protocol,
show_api,
no_browser,
port,
web: web_mode,
target_nodes,
centrality_threshold,
merge_threshold,
debug,
debug_output,
skip_vendor,
max_line_length,
};
crate::demo::run_demo(demo_args, server).await
}
#[allow(clippy::too_many_arguments)]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub async fn handle_quality_gate(
project_path: PathBuf,
file: Option<PathBuf>,
format: QualityGateOutputFormat,
fail_on_violation: bool,
checks: Vec<QualityCheckType>,
max_dead_code: f64,
min_entropy: f64,
max_complexity_p99: u32,
include_provability: bool,
output: Option<PathBuf>,
perf: bool,
) -> Result<()> {
super::super::analysis_utilities::handle_quality_gate(
project_path,
file,
format,
fail_on_violation,
checks,
max_dead_code,
min_entropy,
max_complexity_p99,
include_provability,
output,
perf,
)
.await
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
#[test]
fn test_demo_handlers_basic() {
assert_eq!(1 + 1, 2);
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}