Add AppConfig with overwrite behavior, skill level, thread count settings
All 3 config tests passing.
This commit is contained in:
@@ -1 +1,70 @@
|
||||
// Application configuration
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AppConfig {
|
||||
pub output_subfolder: String,
|
||||
pub output_fixed_path: Option<String>,
|
||||
pub overwrite_behavior: OverwriteBehavior,
|
||||
pub remember_settings: bool,
|
||||
pub skill_level: SkillLevel,
|
||||
pub thread_count: ThreadCount,
|
||||
pub error_behavior: ErrorBehavior,
|
||||
pub notify_on_completion: bool,
|
||||
pub play_completion_sound: bool,
|
||||
pub auto_open_output: bool,
|
||||
pub high_contrast: bool,
|
||||
pub large_text: bool,
|
||||
pub reduced_motion: bool,
|
||||
}
|
||||
|
||||
impl Default for AppConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
output_subfolder: "processed".into(),
|
||||
output_fixed_path: None,
|
||||
overwrite_behavior: OverwriteBehavior::Ask,
|
||||
remember_settings: true,
|
||||
skill_level: SkillLevel::Simple,
|
||||
thread_count: ThreadCount::Auto,
|
||||
error_behavior: ErrorBehavior::SkipAndContinue,
|
||||
notify_on_completion: true,
|
||||
play_completion_sound: false,
|
||||
auto_open_output: false,
|
||||
high_contrast: false,
|
||||
large_text: false,
|
||||
reduced_motion: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum OverwriteBehavior {
|
||||
Ask,
|
||||
AutoRename,
|
||||
Overwrite,
|
||||
Skip,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum SkillLevel {
|
||||
Simple,
|
||||
Detailed,
|
||||
}
|
||||
|
||||
impl SkillLevel {
|
||||
pub fn is_advanced(&self) -> bool {
|
||||
matches!(self, Self::Detailed)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ThreadCount {
|
||||
Auto,
|
||||
Manual(usize),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ErrorBehavior {
|
||||
SkipAndContinue,
|
||||
PauseOnError,
|
||||
}
|
||||
|
||||
27
pixstrip-core/tests/config_tests.rs
Normal file
27
pixstrip-core/tests/config_tests.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use pixstrip_core::config::*;
|
||||
|
||||
#[test]
|
||||
fn default_config() {
|
||||
let config = AppConfig::default();
|
||||
assert_eq!(config.output_subfolder, "processed");
|
||||
assert_eq!(config.overwrite_behavior, OverwriteBehavior::Ask);
|
||||
assert!(config.remember_settings);
|
||||
assert_eq!(config.skill_level, SkillLevel::Simple);
|
||||
assert_eq!(config.thread_count, ThreadCount::Auto);
|
||||
assert_eq!(config.error_behavior, ErrorBehavior::SkipAndContinue);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_serialization_roundtrip() {
|
||||
let config = AppConfig::default();
|
||||
let json = serde_json::to_string(&config).unwrap();
|
||||
let deserialized: AppConfig = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(deserialized.output_subfolder, config.output_subfolder);
|
||||
assert_eq!(deserialized.overwrite_behavior, config.overwrite_behavior);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skill_level_toggle() {
|
||||
assert_eq!(SkillLevel::Simple.is_advanced(), false);
|
||||
assert_eq!(SkillLevel::Detailed.is_advanced(), true);
|
||||
}
|
||||
Reference in New Issue
Block a user