fix(targen): pass patch count to targen -f flag (v0.1.5) #45

Merged
gronod merged 1 commits from fix/issue-44-patch-count-selection into development 2026-08-24 18:14:27 +01:00
5 changed files with 34 additions and 7 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "iccery",
"private": true,
"version": "0.1.4",
"version": "0.1.5",
"type": "module",
"scripts": {
"tauri": "tauri"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "iccery"
version = "0.1.4"
version = "0.1.5"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
+25 -3
View File
@@ -106,6 +106,7 @@ pub async fn extract_gamut(
#[derive(Debug, Deserialize, Serialize)]
pub struct TargenConfig {
pub colour_space: String,
#[serde(default)]
pub patch_count: u32,
pub white_patches: Option<u32>,
pub black_patches: Option<u32>,
@@ -141,7 +142,13 @@ pub fn build_targen_args(config: &TargenConfig) -> Vec<String> {
args.push("2".to_string()); // Default to RGB
}
if let Some(patches) = config.total_patches {
let patches = if config.patch_count > 0 {
config.patch_count
} else {
config.total_patches.unwrap_or(0)
};
if patches > 0 {
args.push("-f".to_string());
args.push(patches.to_string());
}
@@ -526,7 +533,7 @@ mod tests {
patch_count: 800,
white_patches: Some(4),
black_patches: None,
total_patches: Some(800),
total_patches: None,
basename: "my_profile".to_string(),
cwd: "/tmp".to_string(),
};
@@ -541,7 +548,7 @@ mod tests {
patch_count: 1500,
white_patches: None,
black_patches: Some(8),
total_patches: Some(1500),
total_patches: None,
basename: "cmyk_profile".to_string(),
cwd: "/tmp".to_string(),
};
@@ -549,6 +556,21 @@ mod tests {
assert_eq!(args, vec!["-v", "-d", "4", "-f", "1500", "-B", "8", "cmyk_profile"]);
}
#[test]
fn test_build_targen_args_total_patches_fallback() {
let config = TargenConfig {
colour_space: "rgb".to_string(),
patch_count: 0,
white_patches: None,
black_patches: None,
total_patches: Some(400),
basename: "draft_profile".to_string(),
cwd: "/tmp".to_string(),
};
let args = build_targen_args(&config);
assert_eq!(args, vec!["-v", "-d", "2", "-f", "400", "draft_profile"]);
}
#[test]
fn test_build_printtarg_args_i1_a4_8bit() {
let config = PrinttargConfig {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "ICCery",
"version": "0.1.4",
"version": "0.1.5",
"identifier": "com.gronod.iccery",
"build": {
"frontendDist": "../src"
+6 -1
View File
@@ -83,7 +83,11 @@ export function initTargen() {
// Determine patch count
let patchCount = parseInt(patchCountPreset.value, 10);
if (patchCountPreset.value === "custom") {
patchCount = parseInt(patchCountCustom.value, 10);
const customVal = parseInt(patchCountCustom.value, 10);
patchCount = (!isNaN(customVal) && customVal > 0) ? customVal : 800;
}
if (isNaN(patchCount) || patchCount <= 0) {
patchCount = 800;
}
// Determine colour space
@@ -97,6 +101,7 @@ export function initTargen() {
const config = {
colour_space: colourSpace,
patch_count: patchCount,
total_patches: patchCount,
white_patches: whitePatches.value ? parseInt(whitePatches.value, 10) : null,
black_patches: blackPatches.value ? parseInt(blackPatches.value, 10) : null,
basename: basename,