#![allow(clippy::all, clippy::pedantic, clippy::disallowed_methods)]
#![allow(unreachable_code, unused_variables, unused_imports, dead_code, unused_assignments)]
use clap::{Parser, Subcommand};
use std::path::{Path, PathBuf};
#[macro_use]
#[allow(unused_macros, clippy::duplicated_attributes)]
mod generated_contracts;
mod commands;
pub mod error;
mod output;
pub mod pipe;
pub use error::CliError;
pub mod qa_types {
pub use crate::commands::qa::{GateResult, QaReport, SystemInfo};
}
pub mod model_pull {
pub use crate::commands::pull::{list, run};
}
#[cfg(feature = "inference")]
pub mod federation;
use commands::{
bench, canary, canary::CanaryCommands, cbtop, chat, compare_hf, compile, convert, data, debug,
diagnose, diff, distill, eval, explain, export, flow, hex, import, inspect, lint, merge,
oracle, pipeline, probar, profile, prune, ptx_explain, publish, pull, qa, qualify, quantize,
rosetta, rosetta::RosettaCommands, run, serve, showcase, tensors, tokenize, trace, tree, tui,
validate,
};
#[cfg(feature = "training")]
use commands::{finetune, gpu, train, tune};
#[derive(Parser, Debug)]
#[command(name = "apr")]
#[command(author, version = concat!(env!("CARGO_PKG_VERSION"), " (", env!("APR_GIT_SHA"), ")"), about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Box<Commands>,
#[arg(long, global = true)]
pub json: bool,
#[arg(short, long, global = true)]
pub verbose: bool,
#[arg(short, long, global = true)]
pub quiet: bool,
#[arg(long, global = true)]
pub offline: bool,
#[arg(long, global = true)]
pub skip_contract: bool,
}
include!("commands_enum.rs");
include!("model_ops_commands.rs");
include!("extended_commands.rs");
include!("tool_commands.rs");
include!("data_commands.rs");
#[cfg(feature = "training")]
include!("train_commands.rs");
include!("serve_commands.rs");
include!("tokenize_commands.rs");
include!("pipeline_commands.rs");
include!("validate.rs");
include!("dispatch_run.rs");
include!("dispatch.rs");
include!("dispatch_analysis.rs");
include!("lib_07.rs");
pub fn cli_main() -> std::process::ExitCode {
#[cfg(unix)]
#[allow(unsafe_code)]
unsafe {
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
}
#[cfg(target_arch = "aarch64")]
#[allow(unsafe_code)]
unsafe {
let fpcr: u64;
core::arch::asm!("mrs {}, fpcr", out(reg) fpcr);
if fpcr & (1 << 19) != 0 {
let new_fpcr = fpcr & !(1 << 19);
core::arch::asm!("msr fpcr, {}", in(reg) new_fpcr);
}
}
let no_color = std::env::var("NO_COLOR").is_ok();
let is_tty = std::io::IsTerminal::is_terminal(&std::io::stdout());
if no_color || !is_tty {
colored::control::set_override(false);
}
let cli = Cli::parse();
match execute_command(&cli) {
Ok(()) => std::process::ExitCode::SUCCESS,
Err(e) => {
eprintln!("error: {e}");
e.exit_code()
}
}
}