feat: socle BDD (tâche 1.9 Phase 1-2) + moteur APT (tâche 2 SJ-0→3) + WIP capabilities/auth/Rust
Checkpoint multi-chantiers (arbre vert : tsc 0 erreur, 70 tests, build OK). - tâche 1.9 Phase 1 : schéma socle (machine_state/events/reports/raw_artifacts/ hardware/metrics + colonnes étendues) + wiring refresh/execute. Migration 0002. - tâche 1.9 Phase 2 : machine_credentials + machine_host_keys (non destructif, dual-read + backfill). Migration 0003. Fix séquence journal de migration. - tâche 2 : SJ-0 (types étendus rétro-compatibles, réducteur Docker, resolveTemplate), SJ-1 (update-analyze enrichi), SJ-2 (apply + diff dpkg + timeout inactivité SSH), SJ-3 (reboot vérifié boot_id). - WIP parallèle inclus : /api/capabilities, auth/apiTokens/apiClients, system metrics, scaffold app_rust, ajustements frontend. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
mod api;
|
||||
mod config;
|
||||
#[cfg(feature = "gui")]
|
||||
mod gui;
|
||||
mod token_store;
|
||||
|
||||
use api::ApiClient;
|
||||
use config::{AppConfig, Command};
|
||||
use std::env;
|
||||
use std::process::ExitCode;
|
||||
use token_store::keyring_identity;
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
match run(&args) {
|
||||
Ok(()) => ExitCode::SUCCESS,
|
||||
Err(err) => {
|
||||
eprintln!("erreur: {err}");
|
||||
ExitCode::FAILURE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn run(args: &[String]) -> Result<(), String> {
|
||||
let (config, command) = AppConfig::from_args(args)?;
|
||||
|
||||
match command {
|
||||
Command::Capabilities => {
|
||||
let client = ApiClient::new(&config.server_url, config.token)?;
|
||||
let body = client.get_capabilities()?;
|
||||
println!("{body}");
|
||||
}
|
||||
Command::Status => {
|
||||
let client = ApiClient::new(&config.server_url, config.token)?;
|
||||
let body = client.get_system_status()?;
|
||||
println!("{body}");
|
||||
}
|
||||
Command::Metrics => {
|
||||
let client = ApiClient::new(&config.server_url, config.token)?;
|
||||
let body = client.get_system_metrics()?;
|
||||
println!("{body}");
|
||||
}
|
||||
Command::Machines => {
|
||||
let client = ApiClient::new(&config.server_url, config.token)?;
|
||||
let body = client.get_machines()?;
|
||||
println!("{body}");
|
||||
}
|
||||
Command::Gui => run_gui(config)?,
|
||||
Command::Help => print_help(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "gui")]
|
||||
fn run_gui(config: AppConfig) -> Result<(), String> {
|
||||
gui::run(config);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gui"))]
|
||||
fn run_gui(_config: AppConfig) -> Result<(), String> {
|
||||
Err(
|
||||
"l'interface graphique n'est pas compilée. Lance: cargo run --features gui -- gui"
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
fn print_help() {
|
||||
let (keyring_service, keyring_account) = keyring_identity();
|
||||
println!(
|
||||
"system-update-gnome\n\
|
||||
\n\
|
||||
Usage:\n\
|
||||
system-update-gnome --server http://127.0.0.1:8787 capabilities\n\
|
||||
system-update-gnome --server http://127.0.0.1:8787 status\n\
|
||||
system-update-gnome --server http://127.0.0.1:8787 metrics\n\
|
||||
system-update-gnome --server http://127.0.0.1:8787 machines\n\
|
||||
system-update-gnome --server http://127.0.0.1:8787 gui\n\
|
||||
\n\
|
||||
Variables:\n\
|
||||
SYSTEM_UPDATE_SERVER URL du backend, défaut http://127.0.0.1:8787\n\
|
||||
SYSTEM_UPDATE_TOKEN Token API optionnel\n\
|
||||
\n\
|
||||
Futur trousseau:\n\
|
||||
service: {keyring_service}\n\
|
||||
compte: {keyring_account}\n"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user