Skip to main content

apr_cli/
lib.rs

1//! apr-cli library
2//!
3//! This library is the foundation for the apr CLI binary.
4//! Exports CLI structures for testing and reuse.
5
6use clap::{Parser, Subcommand};
7use std::path::{Path, PathBuf};
8
9// Contract assertions from YAML (pv codegen)
10#[macro_use]
11#[allow(unused_macros, clippy::duplicated_attributes)]
12mod generated_contracts;
13
14mod commands;
15pub mod error;
16mod output;
17pub mod pipe;
18
19pub use error::CliError;
20
21// Public re-exports for integration tests
22pub mod qa_types {
23    pub use crate::commands::qa::{GateResult, QaReport, SystemInfo};
24}
25
26// Public re-exports for downstream crates (whisper-apr proxies these)
27pub mod model_pull {
28    pub use crate::commands::pull::{list, run};
29}
30
31#[cfg(feature = "inference")]
32pub mod federation;
33
34// Commands are crate-private, used internally by execute_command
35use commands::{
36    bench, canary, canary::CanaryCommands, cbtop, chat, compare_hf, compile, convert, data, debug,
37    diagnose, diff, distill, eval, explain, export, flow, hex, import, inspect, lint, merge,
38    oracle, pipeline, probar, profile, prune, ptx_explain, publish, pull, qa, qualify, quantize,
39    rosetta, rosetta::RosettaCommands, run, serve, showcase, tensors, tokenize, trace, tree, tui,
40    validate,
41};
42#[cfg(feature = "training")]
43use commands::{finetune, gpu, train, tune};
44
45/// apr - APR Model Operations Tool
46///
47/// Inspect, debug, and manage .apr model files.
48/// Toyota Way: Genchi Genbutsu - Go and see the actual data.
49#[derive(Parser, Debug)]
50#[command(name = "apr")]
51#[command(author, version = concat!(env!("CARGO_PKG_VERSION"), " (", env!("APR_GIT_SHA"), ")"), about, long_about = None)]
52#[command(propagate_version = true)]
53pub struct Cli {
54    #[command(subcommand)]
55    pub command: Box<Commands>,
56
57    /// Output as JSON
58    #[arg(long, global = true)]
59    pub json: bool,
60
61    /// Verbose output
62    #[arg(short, long, global = true)]
63    pub verbose: bool,
64
65    /// Quiet mode (errors only)
66    #[arg(short, long, global = true)]
67    pub quiet: bool,
68
69    /// Disable network access (Sovereign AI compliance, Section 9)
70    #[arg(long, global = true)]
71    pub offline: bool,
72
73    /// Skip tensor contract validation (PMAT-237: use with diagnostic tooling)
74    #[arg(long, global = true)]
75    pub skip_contract: bool,
76}
77
78include!("commands_enum.rs");
79include!("model_ops_commands.rs");
80include!("extended_commands.rs");
81include!("tool_commands.rs");
82include!("data_commands.rs");
83#[cfg(feature = "training")]
84include!("train_commands.rs");
85include!("serve_commands.rs");
86include!("tokenize_commands.rs");
87include!("pipeline_commands.rs");
88include!("validate.rs");
89include!("dispatch_run.rs");
90include!("dispatch.rs");
91include!("dispatch_analysis.rs");
92include!("lib_07.rs");