CLI: --automation-read-root / --automation-write-root for mcp and serve

The spelling the other crafting apps use; the same as --read-root /
--write-root.

Fixes #57.
This commit is contained in:
bflatastic committed 2026-11-02 05:41:00 +07:00
1 parent 3fac2b1482
commit c4353cc8d0
3 files changed
+28 -5

No files matched your search

+7 -4
View File
@@ -38,7 +38,8 @@ USAGE:
New project; --sample bakes and applies a smart material to every texture set.
texturecraft-cli mcp [--bridge <port>] [--token <token>] [--read-root <dir>] [--write-root <dir>]
MCP server on stdio: headless (file access only below the roots), or bridged to
`texturecraft --control <port>`.
`texturecraft --control <port>`. --automation-read-root / --automation-write-root are
the same as --read-root / --write-root (mcp and serve).
texturecraft-cli serve [--port <port>] [--read-root <dir>] [--write-root <dir>]
JSON lines ({\"id\",\"method\",\"params\"}) on stdio, or on 127.0.0.1:<port> with a token.
@@ -57,8 +58,8 @@ const SUBCOMMANDS: &[(&str, &[&str], &[&str])] = &[
("export", &["--preset", "--format", "--padding", "--size"], &[]),
("render", &["--size", "--view", "--camera", "--yaw", "--pitch", "--samples", "--bounces"], &["--cpu"]),
("new", &["--resolution"], &["--sample"]),
("mcp", &["--bridge", "--token", "--read-root", "--write-root"], &[]),
("serve", &["--port", "--read-root", "--write-root"], &[]),
("mcp", &["--bridge", "--token", "--read-root", "--write-root", "--automation-read-root", "--automation-write-root"], &[]),
("serve", &["--port", "--read-root", "--write-root", "--automation-read-root", "--automation-write-root"], &[]),
];
struct Args {
@@ -367,7 +368,9 @@ fn new(a: &Args) -> R {
}
fn workspace(a: &Args) -> Result<Filesystem, String> {
let (r, w) = (a.get("--read-root").map(Path::new), a.get("--write-root").map(Path::new));
// `--automation-*-root` is the spelling the other crafting apps use.
let root = |k: &str| a.get(&format!("--automation-{k}")).or_else(|| a.get(&format!("--{k}"))).map(Path::new);
let (r, w) = (root("read-root"), root("write-root"));
if r.is_none() && w.is_none() {
return Ok(Filesystem::Denied);
}