{"record":{"id":"579577b691e71e4c","repo":"laurent22/joplin","slug":"missing-required-flag-value-s","errorCode":null,"errorMessage":"Missing required flag value: %s","messagePattern":"Missing required flag value: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/cli-utils.ts","lineNumber":169,"sourceCode":"\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) {\n\t\t\t\tthrow new Error(_('Missing required flag value: %s', `-${flagSpec.short} <${flagSpec.arg.name}>`));\n\t\t\t}\n\t\t}\n\t}\n\n\toutput.options = argOptions;\n\n\treturn output;\n};\n\ncliUtils.promptMcq = function(message: string, answers: Record<string, string>): Promise<string> {\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t});\n\n\tmessage += '\\n\\n';\n\tfor (const n in answers) {\n\t\tif (!answers.hasOwnProperty(n)) continue;","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/cli-utils.ts#L151-L187","documentation":"For flags that take a required value (flagSpec.arg.required === true, e.g. '-f <notebook>'), Yargs represents a bare flag (given without a value) as the boolean true. makeCommandArgs detects value === true and throws 'Missing required flag value'. The message is i18n-translated.","triggerScenarios":"Supplying a value-taking flag without its argument — e.g. 'mknote -f' with no notebook name, or 'mkbook -h' style usage where the flag expects a value.","commonSituations":"Forgetting the argument after a flag; a flag that the user assumed was boolean but actually requires a value; shell parsing that detaches the value.","solutions":["Provide the value immediately after the flag: '-f <notebook>'.","Run '<command> --help' to confirm which flags require values (shown as -x <name>).","Quote the value if it contains spaces."],"exampleFix":"# before\n#   joplin mknote -f \"My note\"\n# after\n#   joplin mknote -f \"My notebook\" \"My note\"","handlingStrategy":"validation","validationCode":"for (const [key, value] of Object.entries(argOptions)) {\n  const spec = flagSpecs.find(s => s.short === key || s.long === key);\n  if (spec?.arg?.required && value === true) {\n    throw new Error(`Provide a value for -${spec.short}`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await command.action(cliUtils.makeCommandArgs(command, argv));\n} catch (e) {\n  if (/Missing required flag value/.test(e.message)) command.stdout(command.usage());\n}","preventionTips":["Document value-taking flags clearly in usage() with the -x <name> form.","Validate flag values before dispatch in your own wrappers.","Quote flag values that contain spaces."],"tags":["cli","argument-parsing","flags","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}