{"record":{"id":"35bc4959c05ee25d","repo":"laurent22/joplin","slug":"missing-required-argument-s","errorCode":null,"errorMessage":"Missing required argument: %s","messagePattern":"Missing required argument: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/cli-utils.ts","lineNumber":150,"sourceCode":"\t\t\tif (flags.long) booleanFlags.push(flags.long);\n\t\t}\n\n\t\tif (flags.short && flags.long) {\n\t\t\taliases[flags.long] = [flags.short];\n\t\t}\n\n\t\tflagSpecs.push(flags);\n\t}\n\n\tconst args = yargParser(argv, {\n\t\tboolean: booleanFlags,\n\t\talias: aliases,\n\t\tstring: ['_'],\n\t});\n\n\tfor (let i = 1; i < parsedUsage['_'].length; i++) {\n\t\tconst a = cliUtils.parseCommandArg(parsedUsage['_'][i] as string);\n\t\tif (a.required && !args['_'][i]) throw new Error(_('Missing required argument: %s', a.name));\n\t\toutput[a.name] = args['_'][i];\n\t}\n\n\tconst argOptions: CommandArgs = {};\n\tfor (const key in args) {\n\t\tif (!args.hasOwnProperty(key)) continue;\n\t\tif (key === '_') continue;\n\t\targOptions[key] = args[key];\n\t}\n\n\tfor (const [key, value] of Object.entries(argOptions)) {\n\t\tconst flagSpec = flagSpecs.find(s => {\n\t\t\treturn s.short === key || s.long === key;\n\t\t});\n\t\tif (flagSpec?.arg?.required) {\n\t\t\t// If a flag is required, and no value is provided for it, Yargs\n\t\t\t// sets the value to `true`.\n\t\t\tif (value === true) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/cli-utils.ts#L132-L168","documentation":"cliUtils.makeCommandArgs parses each command's usage spec (e.g. 'attach <note> <file>') to determine required positional arguments. It iterates the positional slots and, for each one marked required, checks that the caller actually supplied a value at that index; if not, it throws 'Missing required argument'. The message is i18n-translated.","triggerScenarios":"Running a command without one of its required positional arguments — e.g. 'cat' with no note title, or 'attach file.txt' missing the note argument.","commonSituations":"Forgetting a required argument; misunderstanding the usage string; shell quoting that swallows an argument.","solutions":["Run '<command> --help' or 'help <command>' to see required arguments (denoted by angle brackets).","Supply all required positional arguments in order.","Verify the usage() spec of the command if you are authoring one."],"exampleFix":"# before\n#   joplin cat\n# after\n#   joplin cat \"my note\"","handlingStrategy":"validation","validationCode":"const required = parsedUsage['_'].map((s, i) => i > 0 ? cliUtils.parseCommandArg(s) : null).filter(Boolean);\nfor (const a of required) {\n  if (!userSupplied[a.name]) throw new Error(`Missing required argument: ${a.name}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await command.action(cliUtils.makeCommandArgs(command, argv));\n} catch (e) {\n  if (/Missing required argument/.test(e.message)) command.stdout(command.usage());\n}","preventionTips":["Always show usage() when this error fires so the user sees required args.","When authoring a command, mark only truly required positionals as required in usage().","Validate argv length against the usage spec before dispatch."],"tags":["cli","argument-parsing","usage","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}