Skip to content

Commit 95633ca

Browse files
committed
Accept equals form run max option
1 parent 942bb37 commit 95633ca

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

bin/moshcode.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ async function main() {
145145
try { max = parseMax(rest[++k]); }
146146
catch (e) { console.error(String(e.message || e)); process.exit(1); }
147147
}
148+
else if (a.startsWith("--max=")) {
149+
try { max = parseMax(a.slice("--max=".length)); }
150+
catch (e) { console.error(String(e.message || e)); process.exit(1); }
151+
}
148152
else if (a === "--dry-run") dryRun = true;
149153
else if (a.startsWith("-")) {
150154
console.error(`moshcode run: unknown option ${a}`);

test/run-options.test.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ test("run rejects unknown options before treating them as files", () => {
2121
assert.match(result.stderr, /moshcode run: unknown option --dryrun/);
2222
});
2323

24+
test("run accepts equals-form max option", () => {
25+
const result = run(["--max=1", "--dry-run"]);
26+
27+
assert.equal(result.status, 0);
28+
assert.match(result.stdout, /1 loop\(s\)/);
29+
});
30+
2431
test("run rejects multiple script files", () => {
2532
const dir = mkdtempSync(join(tmpdir(), "moshcode-run-"));
2633
const first = join(dir, "first.mosh");

0 commit comments

Comments
 (0)