{"record":{"id":"281f525bd31c70e8","repo":"koala73/worldmonitor","slug":"command-needs-a-name-usage-worldmonito","errorCode":null,"errorMessage":"`${command}` needs <${a.name}>. Usage: worldmonitor ${command} <${a.name}>","messagePattern":"`(.+?)` needs <(.+?)>\\. Usage: worldmonitor (.+?) <(.+?)>","errorType":"exception","errorClass":"UsageError","httpStatus":null,"severity":"error","filePath":"cli/src/core.mjs","lineNumber":297,"sourceCode":"      throw new UsageError(\n        '`call` needs a tool name, e.g. `worldmonitor call get_country_risk --country_code IR`',\n      );\n    }\n    return mcpPlan('tools/call', { name: tool, arguments: collectArgs(parsed) }, options, config, {\n      needsKey: true,\n    });\n  }\n\n  if (Object.hasOwn(CURATED_COMMANDS, command)) {\n    const spec = CURATED_COMMANDS[command];\n    const args = {};\n    for (const [k, v] of Object.entries(params)) args[k] = v === true ? true : String(v);\n    spec.args.forEach((a, idx) => {\n      if (positionals[idx] !== undefined) args[a.name] = positionals[idx];\n    });\n    for (const a of spec.args) {\n      if (a.required && args[a.name] === undefined) {\n        throw new UsageError(`\\`${command}\\` needs <${a.name}>. Usage: worldmonitor ${command} <${a.name}>`);\n      }\n    }\n    return mcpPlan('tools/call', { name: spec.tool, arguments: args }, options, config, {\n      needsKey: true,\n    });\n  }\n\n  throw new UsageError(`Unknown command: ${command || '(none)'}. Run \\`worldmonitor --help\\`.`);\n}\n\nexport function formatOutput(value, options = {}) {\n  if (options.raw && typeof value === 'string') return value;\n  if (options.compact) return JSON.stringify(value);\n  return JSON.stringify(value, null, 2);\n}\n\n// Flatten an OpenAPI document into printable operation rows, optionally scoped\n// to one service (the first path segment after /api/).","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/cli/src/core.mjs#L279-L315","documentation":"Curated convenience commands declare an ordered list of positional args. After binding positionals and --key value flags, every arg marked required must be present; the first missing one raises this UsageError naming the command and the missing placeholder (exit code 2).","triggerScenarios":"Invoking a curated command with no or too few positionals; passing the required value as a flag with a different name; an empty-string positional or unset shell variable leaving args[name] undefined.","commonSituations":"Running curated commands from memory without checking --help; scripted invocations where a variable expanded to empty.","solutions":["Run `worldmonitor --help` to see each curated command's positional argument order","Supply the required positional exactly: worldmonitor <command> <value>","In scripts, guard empty variables before invoking: [ -n \"$CC\" ] || { echo 'missing CC'; exit 1; }"],"exampleFix":"# before\nCC=''\nworldmonitor country-risk \"$CC\" 2>/dev/null || worldmonitor country-risk\n# UsageError: `country-risk` needs <country_code>. Usage: worldmonitor country-risk <country_code>\n\n# after — validate inputs, then pass the required positional\n[ -n \"$CC\" ] || exit 1\nworldmonitor country-risk \"$CC\"","handlingStrategy":"validation","validationCode":"// Fill every required positional before invoking a curated command\nconst spec = CURATED[command];            // e.g. { args: [{ name: 'country_code', required: true }] }\nconst missing = spec.args.filter((a) => a.required && values[a.name] == null).map((a) => a.name);\nif (missing.length) throw new Error(`${command}: missing ${missing.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read curated command shapes from --help before scripting them","Fail scripts early on empty environment variables instead of passing them through"],"tags":["cli","usage","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}