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