refactor: simplify pass (trekexecute)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f6bdc2de59
commit
af90e82794
12 changed files with 303 additions and 186 deletions
|
|
@ -116,15 +116,18 @@ const GATES_USAGE = 'usage: --gates takes true, false, closed or open';
|
|||
|
||||
function parseArgs(argv) {
|
||||
const out = {};
|
||||
const setGates = (v) => {
|
||||
const g = gatesValue(v);
|
||||
if (g === undefined) out.error = GATES_USAGE;
|
||||
else out.gates = g;
|
||||
};
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const a = argv[i];
|
||||
if (a === '--state') out.state = argv[++i];
|
||||
else if (a === '--event') out.event = argv[++i];
|
||||
else if (a.startsWith('--gates=')) {
|
||||
// The one-token form, read as `--gates <value>`; an empty value is no value.
|
||||
const g = gatesValue(a.slice('--gates='.length));
|
||||
if (g === undefined) out.error = GATES_USAGE;
|
||||
else out.gates = g;
|
||||
setGates(a.slice('--gates='.length));
|
||||
} else if (a === '--gates') {
|
||||
// Bare `--gates` (last, or followed by another flag) means on and
|
||||
// consumes nothing. A value is case-sensitive: true|closed = on,
|
||||
|
|
@ -133,9 +136,7 @@ function parseArgs(argv) {
|
|||
if (v === undefined || v.startsWith('--')) {
|
||||
out.gates = true;
|
||||
} else {
|
||||
const g = gatesValue(v);
|
||||
if (g === undefined) out.error = GATES_USAGE;
|
||||
else out.gates = g;
|
||||
setGates(v);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue