Refactor code into modular structure and add comprehensive tests

- Split main.rs into 10 focused modules for better maintainability
- Add 37 unit tests covering desktop entry, Tauri config, validation,
  Chromium backend, and app config serialization
- Update version to v0.1.1-alpha.1
This commit is contained in:
Sebastian Palencsar
2026-05-04 18:25:42 +02:00
parent 00ada512b5
commit 1fafa13e4a
12 changed files with 1629 additions and 1281 deletions

161
src/types.rs Normal file
View File

@@ -0,0 +1,161 @@
use clap::{Parser, Subcommand};
#[derive(
clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq,
)]
#[serde(rename_all = "lowercase")]
pub enum Backend {
Tauri,
Chromium,
}
#[derive(
clap::ValueEnum, serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq,
)]
#[serde(rename_all = "lowercase")]
pub enum ProfileScope {
#[serde(alias = "default")]
Isolated,
Shared,
}
#[derive(Debug, Clone)]
pub struct BuildArgs {
pub url: String,
pub name: String,
pub internal_id: String,
pub icon: Option<String>,
pub fullscreen: bool,
pub no_decorations: bool,
pub user_agent: Option<String>,
pub width: Option<f64>,
pub height: Option<f64>,
pub dark_mode: bool,
pub backend: Backend,
pub browser_bin: Option<String>,
pub profile_scope: ProfileScope,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
pub struct DeskifyAppConfig {
pub schema_version: u32,
pub id: String,
pub name: String,
pub url: String,
pub backend: Backend,
pub browser_bin: Option<String>,
pub profile_scope: ProfileScope,
pub fullscreen: bool,
pub no_decorations: bool,
pub user_agent: Option<String>,
pub width: Option<f64>,
pub height: Option<f64>,
pub dark_mode: bool,
}
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Build {
#[arg(short, long)]
url: String,
#[arg(short, long)]
name: String,
#[arg(short, long)]
icon: Option<String>,
#[arg(short, long)]
fullscreen: bool,
#[arg(long)]
no_decorations: bool,
#[arg(short = 'A', long)]
user_agent: Option<String>,
#[arg(short = 'W', long)]
width: Option<f64>,
#[arg(short = 'H', long)]
height: Option<f64>,
#[arg(short, long)]
dark_mode: bool,
#[arg(long, value_enum, default_value_t = Backend::Tauri)]
backend: Backend,
#[arg(long)]
browser_bin: Option<String>,
#[arg(long, value_enum, default_value_t = ProfileScope::Isolated)]
profile_scope: ProfileScope,
#[arg(long)]
print_config: bool,
#[arg(long)]
dry_run: bool,
},
List {
#[arg(long)]
verbose: bool,
},
Doctor,
Remove {
id: String,
},
Update {
id: String,
#[arg(short, long)]
url: Option<String>,
#[arg(short, long)]
name: Option<String>,
#[arg(short, long)]
icon: Option<String>,
#[arg(short, long, action = clap::ArgAction::SetTrue)]
fullscreen: Option<bool>,
#[arg(long, action = clap::ArgAction::SetTrue)]
no_decorations: Option<bool>,
#[arg(short = 'A', long)]
user_agent: Option<String>,
#[arg(short = 'W', long)]
width: Option<f64>,
#[arg(short = 'H', long)]
height: Option<f64>,
#[arg(short, long, action = clap::ArgAction::SetTrue)]
dark_mode: Option<bool>,
#[arg(long, value_enum)]
backend: Option<Backend>,
#[arg(long)]
browser_bin: Option<String>,
#[arg(long, value_enum)]
profile_scope: Option<ProfileScope>,
#[arg(long)]
dry_run: bool,
#[arg(long)]
print_config: bool,
},
}