Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

fix(cli): reject invalid arguments in remaining commands (#307)

ooiuuiia07fa1d5b2a1
diff --git a/archify.zip b/archify.zip
index 20cff800..b4f4d8af 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/bin/archify.mjs b/archify/bin/archify.mjs
index cb6c40f5..5828c43f 100755
--- a/archify/bin/archify.mjs
+++ b/archify/bin/archify.mjs
@@ -1225,8 +1225,10 @@ async function commandPreview(args) {
}
function commandCheck(args) {
+ const unknown = args.find((arg) => arg.startsWith('--'));
+ if (unknown) fail(`Unknown check option "${unknown}".`);
const [html] = args;
- if (!html) fail(usage());
+ if (!html || args.length !== 1) fail(usage());
const result = runNode([path.join(skillRoot, 'scripts/check-render-output.mjs'), html]);
if (result.status !== 0) exitFrom(result);
}
@@ -1283,12 +1285,18 @@ async function commandVisualCheck(args) {
process.exitCode = result.exitCode;
}
-function commandExamples() {
+function commandExamples(args) {
+ const unknown = args.find((arg) => arg.startsWith('--'));
+ if (unknown) fail(`Unknown examples option "${unknown}".`);
+ if (args.length) fail(usage());
const result = runNode([path.join(skillRoot, 'scripts/render-examples.mjs')], { cwd: skillRoot });
if (result.status !== 0) exitFrom(result);
}
-async function commandDoctor() {
+async function commandDoctor(args) {
+ const unknown = args.find((arg) => arg.startsWith('--'));
+ if (unknown) fail(`Unknown doctor option "${unknown}".`);
+ if (args.length) fail(usage());
const checks = [];
const nodeMajor = Number.parseInt(process.versions.node.split('.')[0], 10);
checks.push({
@@ -1536,6 +1544,8 @@ async function commandBrands(args) {
}
function commandDemo(args) {
+ const unknown = args.find((arg) => arg.startsWith('--'));
+ if (unknown) fail(`Unknown demo option "${unknown}".`);
if (args.length > 1) fail(usage());
const outputDirectory = path.resolve(args[0] || process.cwd());
@@ -2070,10 +2080,10 @@ try {
await commandBrands(args);
break;
case 'examples':
- commandExamples();
+ commandExamples(args);
break;
case 'doctor':
- await commandDoctor();
+ await commandDoctor(args);
break;
case 'demo':
commandDemo(args);
diff --git a/archify/test/cli.test.mjs b/archify/test/cli.test.mjs
index 52a8c15c..de2fd91c 100644
--- a/archify/test/cli.test.mjs
+++ b/archify/test/cli.test.mjs
@@ -155,6 +155,18 @@ test('cli: examples renders from an installed skill', () => {
}
});
+test('cli: argument-free commands reject trailing arguments', () => {
+ for (const command of ['examples', 'doctor']) {
+ const extra = run([command, 'ignored-extra']);
+ assert.equal(extra.status, 2, command);
+ assert.match(extra.stderr, /Usage:/, command);
+
+ const unknown = run([command, '--bogus']);
+ assert.equal(unknown.status, 2, command);
+ assert.match(unknown.stderr, new RegExp(`Unknown ${command} option "--bogus"`), command);
+ }
+});
+
test('cli: guide lists all scenario recipes by diagram type', () => {
const result = run(['guide']);
@@ -223,6 +235,17 @@ test('cli: demo defaults to the current directory', () => {
assert.equal(fs.existsSync(path.join(workingDirectory, 'archify-demo.html')), true);
});
+test('cli: demo rejects a mistyped option without creating an output directory', () => {
+ const workingDirectory = path.join(tmp, 'demo-option-guard');
+ fs.mkdirSync(workingDirectory);
+
+ const result = run(['demo', '--typo'], { cwd: workingDirectory });
+
+ assert.equal(result.status, 2);
+ assert.match(result.stderr, /Unknown demo option "--typo"/);
+ assert.deepEqual(fs.readdirSync(workingDirectory), []);
+});
+
test('cli: render writes a diagram html file', () => {
const out = path.join(tmp, 'workflow.html');
const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');
@@ -622,6 +645,20 @@ test('cli: check validates rendered html', () => {
assert.match(result.stdout, /"ok": true/);
});
+test('cli: check rejects unknown options and extra positionals', () => {
+ const out = path.join(tmp, 'workflow-check-args.html');
+ const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');
+ assert.equal(run(['render', 'workflow', input, out]).status, 0);
+
+ const unknown = run(['check', '--json', out]);
+ assert.equal(unknown.status, 2);
+ assert.match(unknown.stderr, /Unknown check option "--json"/);
+
+ const extra = run(['check', out, 'ignored-extra']);
+ assert.equal(extra.status, 2);
+ assert.match(extra.stderr, /Usage:/);
+});
+
test('cli: validate emits structured json without keeping html output', () => {
const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');
const before = new Set(fs.readdirSync(tmp));