diff --git a/Cargo.lock b/Cargo.lock index 7c330ec..6248fee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -667,6 +667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -1285,7 +1286,7 @@ dependencies = [ [[package]] name = "imagod-web" -version = "0.2.0" +version = "0.2.2" dependencies = [ "anyhow", "arboard", @@ -2237,6 +2238,7 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64", "bytes", + "futures-channel", "futures-core", "futures-util", "http", diff --git a/Cargo.toml b/Cargo.toml index c1e8ae1..775c8b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imagod-web" -version = "0.2.0" +version = "0.2.2" edition = "2021" description = "Imago Daemon + Dashboard — Service de capture automatique de screenshots + Dashboard web embarqué" authors = ["Bruno Charest "] @@ -15,7 +15,7 @@ clap = { version = "4", features = ["derive", "env"] } # Async runtime tokio = { version = "1", features = ["full"] } # HTTP Client (API Imago) — rustls pour éviter OpenSSL -reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "stream", "rustls-tls"] } +reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "stream", "rustls-tls", "blocking"] } # Serialization serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/imagod-web-v0.2.2-windows.zip b/imagod-web-v0.2.2-windows.zip new file mode 100644 index 0000000..8b0f825 Binary files /dev/null and b/imagod-web-v0.2.2-windows.zip differ diff --git a/imagod-web-windows.zip b/imagod-web-windows.zip new file mode 100644 index 0000000..35327c7 Binary files /dev/null and b/imagod-web-windows.zip differ diff --git a/src/cli.rs b/src/cli.rs index 7314e4b..4909d13 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,80 +1,105 @@ //! Parsing CLI avec clap use clap::{Parser, Subcommand}; +use std::path::PathBuf; #[derive(Parser)] #[command( name = "imagod-web", - version = env!("CARGO_PKG_VERSION"), - about = "Imago Daemon + Dashboard — Capture automatique de screenshots + Dashboard web embarqué", - long_about = "Service de capture automatique de screenshots vers Imago avec dashboard web embarqué.\n\n\ - Modes :\n \ - Windows : imagod-web start → watcher clipboard + dashboard\n \ - Linux : imagod-web serve → watcher dossier + dashboard" + version = env!("IMAGOD_BUILD_VERSION"), + about = "Imago Daemon + Dashboard — Watcher clipboard et dashboard web", + long_about = "Companion multiplateforme pour le backend Imago. Dashboard web, watcher clipboard, gestionnaire d'upload." )] -pub struct Args { +pub struct Cli { #[command(subcommand)] - pub command: Command, + pub cmd: Command, } #[derive(Subcommand)] pub enum Command { - /// Lancer le watcher + dashboard (Windows uniquement) + /// Lancer le watcher + dashboard Start { - /// Port du dashboard web - #[arg(long, default_value = "9090")] + /// Port d'écoute + #[arg(long, default_value = "9199")] port: u16, - /// Ouvrir le dashboard dans le navigateur + + /// Ouvrir le navigateur #[arg(long)] open_browser: bool, }, - /// Lancer le dashboard web uniquement (Linux/serveur) + + /// Lancer le dashboard web (+ watcher dossier sur Linux) Serve { - /// Port du dashboard web - #[arg(long, default_value = "9090")] + /// Port d'écoute + #[arg(long, default_value = "9199")] port: u16, - /// Interface d'écoute + + /// Adresse d'écoute #[arg(long, default_value = "127.0.0.1")] host: String, - /// Désactiver le watcher clipboard + + /// Désactiver le watcher (surveillance du presse-papier) #[arg(long)] no_watcher: bool, - /// Ouvrir le dashboard dans le navigateur + + /// Ouvrir le navigateur #[arg(long)] open_browser: bool, + + /// Chemin du fichier de configuration + #[arg(long)] + config: Option, }, + /// Arrêter le service Stop, - /// Afficher l'état du service + + /// Afficher l'état Status, + /// Gérer la configuration Config { #[command(subcommand)] action: ConfigAction, }, - /// Installer comme service Windows - Install, + + /// Installer en tant que service Windows + Install { + /// Chemin du fichier de configuration + #[arg(short, long)] + config: Option, + + /// Clé API Imago + #[arg(short, long)] + api_key: Option, + }, + /// Désinstaller le service Windows Uninstall, - /// Afficher les derniers logs - Logs, + + /// Mettre à jour depuis Nexus + Update { + /// Forcer même si déjà à jour + #[arg(short, long)] + force: bool, + + /// URL du serveur Nexus + #[arg(short, long, default_value = "https://nexus.dracodev.net")] + nexus_url: String, + }, } -#[derive(Subcommand, Debug)] +#[derive(Subcommand)] pub enum ConfigAction { - /// Afficher la configuration actuelle + /// Afficher la configuration Show, - /// Modifier un paramètre - Set { - /// Clé de configuration (ex: imago.url) - key: String, - /// Valeur - value: String, - }, - /// Réinitialiser la configuration par défaut + /// Modifier une clé + Set { key: String, value: String }, + /// Réinitialiser Reset, } -pub fn parse() -> Args { - Args::parse() +/// Parse les arguments CLI +pub fn parse() -> Command { + ::parse().cmd } diff --git a/src/config.rs b/src/config.rs index 165b7ef..cf4934b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -160,15 +160,25 @@ impl Config { /// Charge la configuration depuis `%APPDATA%/imagod-web/imagod.toml` pub fn load() -> Result { let path = Self::config_path()?; + Self::load_from(&path) + } + + /// Charge la configuration depuis un chemin spécifique + pub fn load_from(path: &PathBuf) -> Result { if path.exists() { - let content = std::fs::read_to_string(&path) + let content = std::fs::read_to_string(path) .with_context(|| format!("Impossible de lire {}", path.display()))?; let config: Config = toml::from_str(&content) .with_context(|| "Erreur de parsing du fichier de configuration")?; Ok(config) } else { let config = Config::default(); - config.save()?; + // Sauvegarder au chemin spécifié + if let Some(parent) = path.parent() { + std::fs::create_dir_all(parent)?; + } + let content = toml::to_string_pretty(&config)?; + std::fs::write(path, &content)?; Ok(config) } } diff --git a/src/frontend/changelog.html b/src/frontend/changelog.html index 873abaf..889e90d 100644 --- a/src/frontend/changelog.html +++ b/src/frontend/changelog.html @@ -3,7 +3,7 @@ -Changelog — imagod-web v0.2.0+build.32-fb292ea-dirty +Changelog — imagod-web v0.2.2+build.34-8db614c-dirty