{"record":{"id":"08cb8de8ab308ac7","repo":"JanDeDobbeleer/oh-my-posh","slug":"requires-at-least-d-arg-s-only-received-d","errorCode":null,"errorMessage":"requires at least %d arg(s), only received %d","messagePattern":"requires at least (.+?) arg\\(s\\), only received (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmdtree/cmdtree.go","lineNumber":505,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc ExactArgs(n int) PositionalArgs {\n\treturn func(_ *Command, args []string) error {\n\t\tif len(args) != n {\n\t\t\treturn fmt.Errorf(\"accepts %d arg(s), received %d\", n, len(args))\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\nfunc MinimumNArgs(n int) PositionalArgs {\n\treturn func(_ *Command, args []string) error {\n\t\tif len(args) < n {\n\t\t\treturn fmt.Errorf(\"requires at least %d arg(s), only received %d\", n, len(args))\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\nfunc RangeArgs(minimum, maximum int) PositionalArgs {\n\treturn func(_ *Command, args []string) error {\n\t\tif len(args) < minimum || len(args) > maximum {\n\t\t\treturn fmt.Errorf(\"accepts between %d and %d arg(s), received %d\", minimum, maximum, len(args))\n\t\t}\n\n\t\treturn nil\n\t}\n}\n\nfunc OnlyValidArgs(cmd *Command, args []string) error {\n\tif len(cmd.ValidArgs) == 0 {","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/cmdtree/cmdtree.go#L487-L523","documentation":"The command tree's MinimumNArgs(n) validator fires when a command receives fewer positional arguments than the required minimum. Unlike ExactArgs it allows extra arguments, but the minimum must be met. Commands with required inputs (like a shell name for `init`) use this to fail fast with a clear message.","triggerScenarios":"Invoking a command registered with MinimumNArgs(n) with zero or fewer than n positional arguments, e.g. `oh-my-posh init` without specifying a shell.","commonSituations":"Omitting the mandatory shell name (`oh-my-posh init` instead of `oh-my-posh bash`), running an alias or wrapper script that drops arguments, or docs examples that assumed the shell argument.","solutions":["Supply all required positional arguments shown in `oh-my-posh <command> --help`","Quote arguments with spaces so they count as one arg rather than being split","Update shell aliases/functions that call the command without forwarding \"$@\""],"exampleFix":"// before\noh-my-posh init\n// after\noh-my-posh init bash","handlingStrategy":"validation","validationCode":"const minArgs = 1;\nif ((process.argv.length - 2) < minArgs) {\n  throw new Error(`command requires at least ${minArgs} positional argument(s)`);\n}","typeGuard":"function hasMinimumArgs(args, n) { return Array.isArray(args) && args.length >= n; }","tryCatchPattern":"try {\n  runCommand(args);\n} catch (err) {\n  if (err.message.includes('requires at least')) {\n    printUsageAndExit();\n  }\n  throw err;\n}","preventionTips":["Include required positionals in every scripted invocation","Forward \"$@\" in wrapper scripts so args are not dropped","Test commands after upgrading CLI versions"],"tags":["cli","arguments","arity"],"backgroundTag":"missing-required-argument","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}