Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6e7ff6e
Remove fixed size caps and make undo, caches and resources follow the…
vangel76 Dec 3, 2026
aaecd8c
Share one memory-aware cache ledger, stride line blurs, check set all…
vangel76 Dec 3, 2026
09cd9e4
Count Max RAM for file work's share of the system's memory without ro…
vangel76 Dec 3, 2026
4a428dd
Merge remote-tracking branch 'upstream/main' into tc-404-limits
vangel76 Dec 3, 2026
d7b76cb
Keep mesh references in the mesh's folder, refuse files that change w…
vangel76 Dec 3, 2026
63c9b62
Keep set caches until every new one is built, count MaterialX images …
vangel76 Dec 3, 2026
2b06887
Keep the browser build free of an unused import
vangel76 Dec 3, 2026
7dd959b
Bound far bake strokes, reads and decodes by what is left, and refres…
vangel76 Dec 3, 2026
03d68f5
Keep evicted cache bytes counted until freed, evict a lone oversized …
vangel76 Dec 3, 2026
c5ff353
Keep the browser preset library loading, give back unread MaterialX m…
vangel76 Dec 3, 2026
65c7d8e
Merge remote-tracking branch 'upstream/main' into tc-404-limits
vangel76 Dec 3, 2026
0add1aa
Merge remote-tracking branch 'upstream/main' into tc-404-limits
vangel76 Dec 4, 2026
4044400
Count cooks closing the app, the gray paint map, protocol imports, ZI…
vangel76 Dec 4, 2026
8189748
Remove the CPU path tracer's 8192 clamp and the 64 KiB template limit…
vangel76 Dec 4, 2026
e944dbc
Merge remote-tracking branch 'upstream/main' into tc-404-limits
vangel76 Dec 4, 2026
4cae7c0
Bound glTF reference reads before they are read, count the decoder's …
vangel76 Dec 4, 2026
4db8b18
Auto: Integrate main and fix file-work and render lifetimes
chasse20 Dec 4, 2026
f264d97
Auto: Fix extreme bake strokes and integrate main
chasse20 Dec 4, 2026
d1c1ead
Auto: Restrict the atomic batch-write test helper to Unix
chasse20 Dec 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions apps/texturecraft-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ use clap::{Args, FromArgMatches, Parser, Subcommand};
use serde_json::Value;
use texturecraft_automation::agents::WhenAppClosed;

#[path = "args/cache_cap.rs"]
mod cache_cap;

use cache_cap::CacheCap;

/// The end of `--help` of every command.
const EXIT_STATUS: &str = "Exit status:\n 0 success\n 1 a command failed\n 2 usage error\n\nA process ended by a signal exits 128 + the signal number (130 for Ctrl-C), as in the shell.";

Expand All @@ -21,6 +26,76 @@ const INPUTS: &str = "An <INPUT> is a .tcraft project, a mesh file (.glb .gltf .
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) command: Command,
#[command(flatten)]
pub(crate) prefs: PrefsArgs,
}

/// The desktop app's settings every command works with: read from its saved settings, unless
/// --no-prefs, then each flag given wins
#[derive(Args, Debug, Default)]
pub(crate) struct PrefsArgs {
/// Ignore the desktop app's saved settings and start from the defaults
#[arg(long, global = true)]
pub(crate) no_prefs: bool,
/// Folder of brushes, project templates and export templates (Settings > Files > Data folder)
#[arg(long, global = true, value_name = "DIR")]
pub(crate) data_folder: Option<String>,
/// Worker threads (0: one per logical CPU)
#[arg(long, global = true, value_name = "N")]
pub(crate) threads: Option<u32>,
/// Cores saving, export, import and bakes leave free
#[arg(long, global = true, value_name = "N")]
pub(crate) reserved_cores: Option<u32>,
/// Share of free RAM saving, export and import may use, in percent
#[arg(long, global = true, value_name = "PERCENT", value_parser = clap::value_parser!(u8).range(0..=100))]
pub(crate) ram_percent: Option<u8>,
/// Largest decompressed project accepted on open, in GiB
#[arg(long, global = true, value_name = "GIB", value_parser = clap::value_parser!(u32).range(1..))]
pub(crate) open_limit_gib: Option<u32>,
/// A cap on the rebuildable caches in MiB, or `auto` to keep them while memory is free
#[arg(long, global = true, value_name = "MIB|auto", value_parser = cache_cap)]
pub(crate) cache_budget_mib: Option<CacheCap>,
/// Undo steps kept (0: every step)
#[arg(long, global = true, value_name = "N")]
pub(crate) undo_steps: Option<u32>,
/// Cast bake rays on the GPU when one is available
#[arg(long, global = true, value_name = "BOOL")]
pub(crate) gpu_raytracing: Option<bool>,
}

/// `--cache-budget-mib`: `auto` or a cap in MiB
fn cache_cap(text: &str) -> Result<CacheCap, String> {
if text.trim().eq_ignore_ascii_case("auto") {
return Ok(CacheCap(None));
}

text.trim().parse::<u32>().map(|mib| CacheCap(Some(mib))).map_err(|_| format!("expected a number of MiB or auto, not {text}"))
}

impl PrefsArgs {
/// The saved settings (or the defaults with --no-prefs) with the flags applied
pub(crate) fn prefs(&self) -> texturecraft_automation::DesktopPrefs {
let saved = if self.no_prefs { texturecraft_automation::DesktopPrefs::default() } else { texturecraft_automation::DesktopPrefs::load() };
self.apply_to(saved)
}

/// `prefs` with each given flag applied
fn apply_to(&self, mut prefs: texturecraft_automation::DesktopPrefs) -> texturecraft_automation::DesktopPrefs {
// A relative folder is taken from the working directory, as the user typed it
if let Some(folder) = &self.data_folder {
// The folder is valid Unicode (clap refuses others); an absolute form that is not, from
// the working directory, keeps the folder as typed rather than naming another one
prefs.data_folder = std::path::absolute(folder).ok().and_then(|path| path.into_os_string().into_string().ok()).unwrap_or_else(|| folder.clone());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
prefs.work_threads = self.threads.unwrap_or(prefs.work_threads);
prefs.reserved_cores = self.reserved_cores.unwrap_or(prefs.reserved_cores);
prefs.save_ram_percent = self.ram_percent.unwrap_or(prefs.save_ram_percent);
prefs.project_open_limit_gib = self.open_limit_gib.unwrap_or(prefs.project_open_limit_gib);
prefs.cache_budget_mib = self.cache_budget_mib.map_or(prefs.cache_budget_mib, |cap| cap.0);
prefs.undo_history_steps = self.undo_steps.unwrap_or(prefs.undo_history_steps);
prefs.gpu_raytracing = self.gpu_raytracing.unwrap_or(prefs.gpu_raytracing);
prefs
}
}

#[derive(Subcommand, Debug)]
Expand Down Expand Up @@ -460,3 +535,38 @@ pub(crate) fn parse(args: &[OsString], window: &dyn Fn() -> bool) -> Result<Cli,
cli.command.check(window).map_err(|(sub, e)| e.into_clap(sub))?;
Ok(cli)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn flags_win_over_the_saved_settings_and_no_prefs_starts_from_the_defaults() {
let folder = std::env::temp_dir().join("studio-data");
let args = [OsString::from("--no-prefs"), "--undo-steps".into(), "0".into(), "--data-folder".into(), folder.clone().into(), "commands".into()];

let prefs = parse(&args, &|| false).unwrap().prefs.prefs();

assert_eq!((prefs.undo_history_steps, prefs.data_folder.as_str()), (0, folder.to_str().unwrap()));
assert_eq!(prefs.save_ram_percent, texturecraft_automation::DesktopPrefs::default().save_ram_percent);
}

#[test]
fn a_flag_replaces_a_saved_value_and_a_missing_flag_keeps_it() {
const SAVED_CACHE_MIB: u32 = 512;
let saved = texturecraft_automation::DesktopPrefs { cache_budget_mib: Some(SAVED_CACHE_MIB), ..Default::default() };
let flags = |args: &[&str]| parse(&args.iter().map(OsString::from).collect::<Vec<_>>(), &|| false).unwrap().prefs;

assert_eq!(flags(&["--cache-budget-mib", "auto", "commands"]).apply_to(saved.clone()).cache_budget_mib, None);
assert_eq!(flags(&["commands"]).apply_to(saved).cache_budget_mib, Some(SAVED_CACHE_MIB));
}

#[cfg(unix)]
#[test]
fn a_data_folder_that_is_not_unicode_is_refused_not_renamed() {
use std::os::unix::ffi::OsStringExt as _;
let args = [OsString::from("--data-folder"), OsString::from_vec(b"/data-\xff".to_vec()), "commands".into()];

assert!(parse(&args, &|| false).is_err(), "a lossy copy would name another folder");
}
}
3 changes: 3 additions & 0 deletions apps/texturecraft-cli/src/args/cache_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// `--cache-budget-mib`: a cap on the rebuildable caches in MiB, or None for Auto
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct CacheCap(pub(crate) Option<u32>);
75 changes: 40 additions & 35 deletions apps/texturecraft-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use clap::CommandFactory;
use serde_json::{Value, json};
use texturecraft_automation::agents;
use texturecraft_automation::security::{client_token, server_token};
use texturecraft_automation::{AuthorizedWorkspace, BridgeClient, Filesystem, Headless, RenderOptions, TexturecraftMcp, rpc};
use texturecraft_automation::{AuthorizedWorkspace, BridgeClient, DesktopPrefs, Filesystem, Headless, RenderOptions, TexturecraftMcp, rpc};
use texturecraft_engine::formats::{MeshReport, import_mesh, import_mesh_bytes, mesh_report};

use args::{
Expand Down Expand Up @@ -112,7 +112,12 @@ where
return e.exit_code();
}
};
match dispatch(cli.command, &window, out, err) {
// Work like the desktop app: its saved settings, then the flags, before the first parallel job
let prefs = cli.prefs.prefs();
prefs.apply_work_threads();
prefs.apply_resource_limits();

match dispatch(cli.command, &prefs, &window, out, err) {
Ok(()) => 0,
Err(e) => {
outln!(err, "error: {e}");
Expand All @@ -121,18 +126,18 @@ where
}
}

fn dispatch(command: Command, window: &dyn Fn() -> bool, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
fn dispatch(command: Command, prefs: &DesktopPrefs, window: &dyn Fn() -> bool, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
match command {
Command::Info(a) => info(&a, out),
Command::Commands(a) => commands(&a, out),
Command::Run(a) => run_command(&a, out, err),
Command::Batch(a) => batch(&a, out, err),
Command::Bake(a) => bake(&a, out, err),
Command::Export(a) => export(&a, out, err),
Command::Render(a) => render(&a, err),
Command::New(a) => new(&a, err),
Command::Mcp(a) => mcp(&a, window(), err),
Command::Serve(a) => serve(&a, err),
Command::Info(a) => info(&a, prefs, out),
Command::Commands(a) => commands(&a, prefs, out),
Command::Run(a) => run_command(&a, prefs, out, err),
Command::Batch(a) => batch(&a, prefs, out, err),
Command::Bake(a) => bake(&a, prefs, out, err),
Command::Export(a) => export(&a, prefs, out, err),
Command::Render(a) => render(&a, prefs, err),
Command::New(a) => new(&a, prefs, err),
Command::Mcp(a) => mcp(&a, prefs, window(), err),
Command::Serve(a) => serve(&a, prefs, err),
}
}

Expand All @@ -141,8 +146,8 @@ fn print(out: &mut dyn Write, v: &Value) {
}

/// A trusted local session on `input`: a project, a mesh file or `builtin:<id>`.
fn open(input: &Path, resolution: Option<u32>) -> Result<Headless, CliError> {
let mut h = Headless::new(Headless::default_session()?, Filesystem::TrustedLocal);
fn open(input: &Path, resolution: Option<u32>, prefs: &DesktopPrefs) -> Result<Headless, CliError> {
let mut h = Headless::with_prefs(Headless::default_session()?, Filesystem::TrustedLocal, prefs);
match input.to_str().and_then(|text| text.strip_prefix("builtin:")) {
Some(id) => h.command_run("project.new", json!({"mesh": id, "resolution": resolution.unwrap_or(1024), "name": id})).map(|_| ())?,
None if is_project(input) => h.open(unicode(input)?).map(|_| ())?,
Expand All @@ -168,7 +173,7 @@ fn report_json(r: &MeshReport) -> Value {
})
}

fn info(a: &InfoArgs, out: &mut dyn Write) -> Result<(), CliError> {
fn info(a: &InfoArgs, prefs: &DesktopPrefs, out: &mut dyn Write) -> Result<(), CliError> {
let file = unicode(&a.input)?;
if let Some(id) = file.strip_prefix("builtin:") {
let m = texturecraft_engine::geom::primitives::builtin(id).ok_or_else(|| CliError::UnknownBuiltin(id.to_string()))?;
Expand All @@ -193,7 +198,7 @@ fn info(a: &InfoArgs, out: &mut dyn Write) -> Result<(), CliError> {
);
return Ok(());
}
let h = open(&a.input, None)?;
let h = open(&a.input, None, prefs)?;
let mut v = h.inspect();
v["file"] = json!(file);
v["kind"] = json!("project");
Expand All @@ -209,8 +214,8 @@ fn info(a: &InfoArgs, out: &mut dyn Write) -> Result<(), CliError> {
Ok(())
}

fn commands(a: &CommandsArgs, out: &mut dyn Write) -> Result<(), CliError> {
let h = open(Path::new("builtin:cube"), Some(128))?;
fn commands(a: &CommandsArgs, prefs: &DesktopPrefs, out: &mut dyn Write) -> Result<(), CliError> {
let h = open(Path::new("builtin:cube"), Some(128), prefs)?;
let list = h.command_list(a.filter.as_deref());
if a.json {
print(out, &list);
Expand All @@ -223,16 +228,16 @@ fn commands(a: &CommandsArgs, out: &mut dyn Write) -> Result<(), CliError> {
Ok(())
}

fn run_command(a: &RunArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
let mut h = open(&a.input, None)?;
fn run_command(a: &RunArgs, prefs: &DesktopPrefs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
let mut h = open(&a.input, None, prefs)?;
print(out, &h.command_run(&a.id, a.params.clone().unwrap_or_else(|| json!({})))?);
match &a.output {
Some(path) => save(&mut h, path, err),
None => Ok(()),
}
}

fn batch(a: &BatchArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
fn batch(a: &BatchArgs, prefs: &DesktopPrefs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
let text = std::fs::read_to_string(&a.script).map_err(|e| CliError::Read { path: a.script.clone(), message: e.to_string() })?;
let script: Value = serde_json::from_str(&text).map_err(|source| CliError::Script { path: a.script.clone(), source })?;
let steps = script.as_array().or_else(|| script.get("steps").and_then(Value::as_array)).ok_or(CliError::ScriptShape)?;
Expand All @@ -246,7 +251,7 @@ fn batch(a: &BatchArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(),
let input = path_field("open")?.unwrap_or("builtin:material_ball");
let output = path_field("save")?;

let mut h = open(Path::new(input), None)?;
let mut h = open(Path::new(input), None, prefs)?;
let reply = h.batch(steps);
print(out, &reply);
if let Some(failure) = reply.get("failed").filter(|failure| !failure.is_null()) {
Expand All @@ -262,7 +267,7 @@ fn batch(a: &BatchArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(),
}
}

fn bake(a: &BakeArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
fn bake(a: &BakeArgs, prefs: &DesktopPrefs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
// `check` has seen to it: a project without -o is saved in place (--in-place), a mesh has -o.
let target = a.output.as_deref().unwrap_or(&a.input);
let mut p = json!({"ts": "all"});
Expand All @@ -272,14 +277,14 @@ fn bake(a: &BakeArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), Cl
if !a.maps.is_empty() {
p["maps"] = json!(a.maps.iter().map(|m| m.trim()).filter(|m| !m.is_empty()).collect::<Vec<_>>());
}
let mut h = open(&a.input, None)?;
let mut h = open(&a.input, None, prefs)?;
h.command_run("bake.run", p)?;
save(&mut h, target, err)?;
print(out, &h.inspect()["textureSets"]);
Ok(())
}

fn export(a: &ExportArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
fn export(a: &ExportArgs, prefs: &DesktopPrefs, out: &mut dyn Write, err: &mut dyn Write) -> Result<(), CliError> {
let mut p = json!({"dir": unicode(&a.dir)?});
for (key, value) in [("preset", &a.preset), ("format", &a.format), ("padding", &a.padding)] {
if let Some(v) = value {
Expand All @@ -289,7 +294,7 @@ fn export(a: &ExportArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<()
if let Some(v) = a.size {
p["size"] = json!(v);
}
let mut h = open(&a.input, None)?;
let mut h = open(&a.input, None, prefs)?;
let r = h.export(&p)?;
for w in r["warnings"].as_array().into_iter().flatten() {
outln!(err, "warning: {}", w.as_str().unwrap_or_default());
Expand All @@ -300,7 +305,7 @@ fn export(a: &ExportArgs, out: &mut dyn Write, err: &mut dyn Write) -> Result<()
Ok(())
}

fn render(a: &RenderArgs, err: &mut dyn Write) -> Result<(), CliError> {
fn render(a: &RenderArgs, prefs: &DesktopPrefs, err: &mut dyn Write) -> Result<(), CliError> {
let options = RenderOptions {
view: a.view.clone(),
width: a.size.map(|s| s.width),
Expand All @@ -311,7 +316,7 @@ fn render(a: &RenderArgs, err: &mut dyn Write) -> Result<(), CliError> {
bounces: a.bounces,
cpu: a.cpu,
};
let mut h = open(&a.input, None)?;
let mut h = open(&a.input, None, prefs)?;
if let Some(name) = &a.camera {
h.command_run("camera.select", json!({ "name": name }))?;
}
Expand All @@ -323,11 +328,11 @@ fn render(a: &RenderArgs, err: &mut dyn Write) -> Result<(), CliError> {
Ok(())
}

fn new(a: &NewArgs, err: &mut dyn Write) -> Result<(), CliError> {
fn new(a: &NewArgs, prefs: &DesktopPrefs, err: &mut dyn Write) -> Result<(), CliError> {
if is_project(&a.input) {
return Err(CliError::AlreadyProject(a.input.clone()));
}
let mut h = open(&a.input, a.resolution)?;
let mut h = open(&a.input, a.resolution, prefs)?;
if a.sample {
let bake_res = h.session.doc.project.texture_sets.first().map_or(1024, |t| t.resolution.min(1024));
h.command_run("bake.run", json!({"ts": "all", "resolution": bake_res}))?;
Expand All @@ -351,7 +356,7 @@ fn workspace(roots: &RootArgs) -> Result<Filesystem, CliError> {
/// `mcp`: with the suite's AI-MCP flag, the open window while agents may use it, otherwise
/// headless (`texturecraft_automation::live`); without the flag, and with `--headless`, headless as
/// before it; `--bridge` (deprecated) an app started with `texturecraft --control`.
fn mcp(a: &McpArgs, window: bool, err: &mut dyn Write) -> Result<(), CliError> {
fn mcp(a: &McpArgs, prefs: &DesktopPrefs, window: bool, err: &mut dyn Write) -> Result<(), CliError> {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let server = match a.bridge {
Some(port) => {
outln!(
Expand All @@ -361,7 +366,7 @@ fn mcp(a: &McpArgs, window: bool, err: &mut dyn Write) -> Result<(), CliError> {
TexturecraftMcp::bridge(BridgeClient::new(port, client_token(port, a.token.clone())?))
}
None if a.live(window) => TexturecraftMcp::live(live_config(a)?),
None => TexturecraftMcp::headless(Headless::new(Headless::default_session()?, workspace(&a.roots)?)),
None => TexturecraftMcp::headless(Headless::with_prefs(Headless::default_session()?, workspace(&a.roots)?, prefs)),
};
let rt = tokio::runtime::Builder::new_multi_thread().enable_all().build().map_err(CliError::Serve)?;
rt.block_on(server.serve_stdio()).map_err(|e| CliError::Automation(texturecraft_automation::AutomationError::Other(e.to_string())))
Expand All @@ -388,8 +393,8 @@ fn live_config(a: &McpArgs) -> Result<texturecraft_automation::live::LiveConfig,
Ok(config)
}

fn serve(a: &ServeArgs, err: &mut dyn Write) -> Result<(), CliError> {
let h = Arc::new(Mutex::new(Headless::new(Headless::default_session()?, workspace(&a.roots)?)));
fn serve(a: &ServeArgs, prefs: &DesktopPrefs, err: &mut dyn Write) -> Result<(), CliError> {
let h = Arc::new(Mutex::new(Headless::with_prefs(Headless::default_session()?, workspace(&a.roots)?, prefs)));
match a.port {
None => rpc::serve_lines(&h, std::io::stdin().lock(), std::io::stdout().lock()).map_err(CliError::Serve)?,
Some(port) => {
Expand Down
6 changes: 4 additions & 2 deletions apps/texturecraft-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ fn cli_binary_path(runner_path: Option<OsString>) -> OsString {
}

fn cli(args: &[&str]) -> Output {
Command::new(cli_binary()).args(args).output().unwrap()
// A settings folder without saved settings keeps the machine's desktop settings out of the tests
let no_settings = std::env::temp_dir().join(format!("tc-cli-no-settings-{}", std::process::id()));
Command::new(cli_binary()).args(args).env("TEXTURECRAFT_DATA_DIR", no_settings).output().unwrap()
}

fn ok(args: &[&str]) -> String {
Expand Down Expand Up @@ -46,7 +48,7 @@ fn version_and_usage_errors() {
let v = ok(&["--version"]);
assert!(v.starts_with("texturecraft-cli "), "{v}");
assert_eq!(v.lines().count(), 1);
assert!(ok(&["--help"]).contains("Usage: texturecraft-cli <COMMAND>"));
assert!(ok(&["--help"]).contains("Usage: texturecraft-cli [OPTIONS] <COMMAND>"));
assert_eq!(cli(&[]).status.code(), Some(2));
assert_eq!(cli(&["frobnicate"]).status.code(), Some(2));
assert_eq!(cli(&["info", "--bogus"]).status.code(), Some(2));
Expand Down
2 changes: 1 addition & 1 deletion apps/texturecraft-cli/tests/it/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn every_subcommand_takes_the_version_and_there_is_no_version_subcommand() {
fn no_arguments_is_a_usage_error_that_prints_the_help_on_stderr() {
let got = invoke(Vec::<OsString>::new());
assert_eq!((got.code, got.out.as_str()), (2, ""));
assert!(got.err.contains("Usage: texturecraft-cli <COMMAND>"), "{}", got.err);
assert!(got.err.contains("Usage: texturecraft-cli [OPTIONS] <COMMAND>"), "{}", got.err);
}

#[test]
Expand Down
5 changes: 5 additions & 0 deletions apps/texturecraft-cli/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ where
I: IntoIterator<Item = T>,
T: Into<OsString>,
{
// The tests must not depend on the desktop settings of the machine running them; no arguments stays no arguments
let mut args: Vec<OsString> = args.into_iter().map(Into::into).collect();
if !args.is_empty() {
args.insert(0, OsString::from("--no-prefs"));
}
let (mut out, mut err) = (Vec::new(), Vec::new());
// As on a computer without the AI-MCP flag, whatever flags this one has: `mcp` never looks for the open window.
let code = texturecraft_cli::run_without_window(args, &mut out, &mut err);
Expand Down
Loading
Loading