From 95633cabf03ccddb6855fba532d21927ea47db6f Mon Sep 17 00:00:00 2001 From: aiirvizionz Date: Sun, 12 Jul 2026 17:52:12 -0600 Subject: [PATCH] Accept equals form run max option --- bin/moshcode.mjs | 4 ++++ test/run-options.test.mjs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/bin/moshcode.mjs b/bin/moshcode.mjs index 3cb4142..f90e5e1 100755 --- a/bin/moshcode.mjs +++ b/bin/moshcode.mjs @@ -145,6 +145,10 @@ async function main() { try { max = parseMax(rest[++k]); } catch (e) { console.error(String(e.message || e)); process.exit(1); } } + else if (a.startsWith("--max=")) { + try { max = parseMax(a.slice("--max=".length)); } + catch (e) { console.error(String(e.message || e)); process.exit(1); } + } else if (a === "--dry-run") dryRun = true; else if (a.startsWith("-")) { console.error(`moshcode run: unknown option ${a}`); diff --git a/test/run-options.test.mjs b/test/run-options.test.mjs index 954c299..168be5d 100644 --- a/test/run-options.test.mjs +++ b/test/run-options.test.mjs @@ -21,6 +21,13 @@ test("run rejects unknown options before treating them as files", () => { assert.match(result.stderr, /moshcode run: unknown option --dryrun/); }); +test("run accepts equals-form max option", () => { + const result = run(["--max=1", "--dry-run"]); + + assert.equal(result.status, 0); + assert.match(result.stdout, /1 loop\(s\)/); +}); + test("run rejects multiple script files", () => { const dir = mkdtempSync(join(tmpdir(), "moshcode-run-")); const first = join(dir, "first.mosh");