{
  "classes": [
    {
      "constants": [],
      "types": [],
      "name": "@eryx/argparse",
      "tags": [],
      "functions": [],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": "Imperative command-line argument parser.\n\nSupports positional arguments, flags, options with values, subcommands,\nand merged short flags. A built-in `--help`/`-h` flag is registered by\ndefault and can be customised or disabled.\n\n```luau\nlocal argparse = require(\"@eryx/argparse\")\n\nlocal parser = argparse.Parser.new(\"mytool\", \"A handy CLI\")\nparser:addPositional(\"file\", \"string\", nil, true, \"Input file\")\nparser:addFlag(\"verbose\", \"v\", \"Enable verbose output\")\nparser:addOption(\"port\", \"p\", \"number\", 8080, nil, \"Port to listen on\")\n\nlocal run = parser:addSubCommand(\"run\", \"Run a script\")\nrun:addPositional(\"script\", \"string\", nil, true, \"Script to run\")\n\nlocal config = parser:parse()\n```\n"
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 69
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "name: string",
          "name": "name",
          "desc": "The program or subcommand name shown in help text."
        },
        {
          "tags": [],
          "lua_type": "description: string?",
          "name": "description",
          "desc": "One-line summary printed below the usage line."
        },
        {
          "tags": [],
          "lua_type": "epilog: string?",
          "name": "epilog",
          "desc": "Text printed at the very end of help output."
        },
        {
          "tags": [],
          "lua_type": "positionals: { PositionalSpec }",
          "name": "positionals",
          "desc": "Registered positional arguments, in order."
        },
        {
          "tags": [],
          "lua_type": "flags: { TFlag }",
          "name": "flags",
          "desc": "Registered boolean flags."
        },
        {
          "tags": [],
          "lua_type": "options: { OptionSpec }",
          "name": "options",
          "desc": "Registered key-value options."
        },
        {
          "tags": [],
          "lua_type": "subCommands: { [string]: Parser }",
          "name": "subCommands",
          "desc": "Registered subcommands, keyed by name."
        },
        {
          "tags": [],
          "lua_type": "mutexGroups: { MutuallyExclusiveGroup }",
          "name": "mutexGroups",
          "desc": "Mutually exclusive groups of flag/option names."
        },
        {
          "tags": [],
          "lua_type": "_helpEnabled: boolean",
          "name": "_helpEnabled",
          "desc": "Whether the built-in `--help` / `-h` behavior is active."
        }
      ],
      "desc": "A command-line parser that can be configured with positional arguments,\nboolean flags, key-value options, and subcommands.\n\nEvery new parser comes with a built-in `--help`/`-h` flag. Use\n[[Parser.disableHelp]] to remove it or [[Parser.setHelpHandler]] to replace its\nbehaviour.\n",
      "name": "Parser",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 88
          },
          "is_method": true,
          "signature": "Parser:_helpHandler() → ()",
          "desc": "The function invoked when `--help` is parsed.",
          "tags": [],
          "name": "_helpHandler",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 111
          },
          "is_method": false,
          "signature": "Parser.new(\n    name: string,  -- The program or subcommand name shown in usage text.\n    description: string?,  -- One-line summary printed below the usage line.\n    epilog: string?  -- Text printed at the very end of help output.\n) → (\n    Parser  -- A new parser ready to be configured. \n)",
          "owner": "Parser",
          "desc": "Creates a new [[Parser]].\n\nThe parser starts with a built-in `--help`/`-h` flag that prints\ngenerated help text and exits.\n",
          "tags": [],
          "name": "new",
          "return_str": "Parser",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "Parser",
              "desc": "A new parser ready to be configured. "
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "name",
              "desc": "The program or subcommand name shown in usage text."
            },
            {
              "lua_type": "string?",
              "name": "description",
              "desc": "One-line summary printed below the usage line."
            },
            {
              "lua_type": "string?",
              "name": "epilog",
              "desc": "Text printed at the very end of help output."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 169
          },
          "is_method": true,
          "signature": "Parser:addSubCommand(\n    name: string,  -- The subcommand name (must not collide with an existing subcommand).\n    description: string?,  -- One-line summary shown in help text.\n    epilog: string?  -- Text printed at the end of the subcommand's help.\n) → (\n    Parser  -- The new subcommand parser, ready to be configured.\n)",
          "owner": "Parser",
          "desc": "Registers a subcommand under this parser.\n\nWhen the subcommand name is encountered during parsing, all remaining\narguments are delegated to the subcommand's parser. The subcommand's\nresult table is stored under its name in the parent result.\n",
          "tags": [],
          "name": "addSubCommand",
          "return_str": "Parser",
          "function_type": "Method",
          "errors": [
            {
              "desc": "Throws if a subcommand with the same name is already registered. "
            }
          ],
          "returns": [
            {
              "lua_type": "Parser",
              "desc": "The new subcommand parser, ready to be configured."
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "name",
              "desc": "The subcommand name (must not collide with an existing subcommand)."
            },
            {
              "lua_type": "string?",
              "name": "description",
              "desc": "One-line summary shown in help text."
            },
            {
              "lua_type": "string?",
              "name": "epilog",
              "desc": "Text printed at the end of the subcommand's help."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 183
          },
          "is_method": true,
          "signature": "Parser:disableHelp() → ()",
          "owner": "Parser",
          "desc": "Removes the built-in `--help`/`-h` flag and sets the help handler to\na no-op. After calling this, `--help` and `-h` are free to be\nre-registered as custom flags or options.\n",
          "tags": [],
          "name": "disableHelp",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 210
          },
          "is_method": true,
          "signature": "Parser:setHelpHandler(\n    handler: ((self: Parser) → ())  -- A function called when `--help` or `-h` is parsed. \n) → ()",
          "owner": "Parser",
          "desc": "Replaces the built-in help behaviour with a custom handler.\n\nThe handler receives the parser so it can call [[Parser.generateHelp]] or\ninspect registered arguments. The built-in `--help`/`-h` flag remains\nregistered; only the action changes.\n\n```luau\nparser:setHelpHandler(function(p)\n\tio.write(p:generateHelp())\n\tos.exit(2)\nend)\n```\n",
          "tags": [],
          "name": "setHelpHandler",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "((self: Parser) → ())",
              "name": "handler",
              "desc": "A function called when `--help` or `-h` is parsed. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 237
          },
          "is_method": true,
          "signature": "Parser:addPositional(\n    name: string,  -- Key used in the result table.\n    type: \"string\" | \"number\",  -- `\"string\"` or `\"number\"` - numeric values are coerced automatically.\n    default: any?,  -- Default value when omitted. Implies optional when non-nil.\n    required: boolean?,  -- Whether the argument must be provided. Defaults to `true` unless a default is given.\n    description: string?,  -- Human-readable text shown in help output.\n    variadic: boolean?  -- Whether this positional should consume all remaining values.\n) → ()",
          "owner": "Parser",
          "desc": "Registers a positional argument.\n\nPositional arguments are consumed left-to-right in the order they are\nadded. Required positionals must come before any optional ones.\n\nIf a `default` is provided the positional is automatically optional.\nTo make a positional optional with no default, pass `nil` for default\nand `false` for required.\n\nSet `variadic` to `true` to let the positional consume all remaining\narguments. Variadic positionals must be the final positional.\n",
          "tags": [],
          "name": "addPositional",
          "return_str": "",
          "function_type": "Method",
          "errors": [
            {
              "desc": "Throws if a positional with the same name already exists."
            },
            {
              "desc": "Throws if a required positional is added after an optional one."
            },
            {
              "desc": "Throws if a default is provided for a required positional. "
            }
          ],
          "returns": [],
          "params": [
            {
              "lua_type": "string",
              "name": "name",
              "desc": "Key used in the result table."
            },
            {
              "lua_type": "\"string\" | \"number\"",
              "name": "type",
              "desc": "`\"string\"` or `\"number\"` - numeric values are coerced automatically."
            },
            {
              "lua_type": "any?",
              "name": "default",
              "desc": "Default value when omitted. Implies optional when non-nil."
            },
            {
              "lua_type": "boolean?",
              "name": "required",
              "desc": "Whether the argument must be provided. Defaults to `true` unless a default is given."
            },
            {
              "lua_type": "string?",
              "name": "description",
              "desc": "Human-readable text shown in help output."
            },
            {
              "lua_type": "boolean?",
              "name": "variadic",
              "desc": "Whether this positional should consume all remaining values."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 290
          },
          "is_method": true,
          "signature": "Parser:addFlag(\n    longName: string,  -- The `--long` name (without dashes).\n    shortName: string?,  -- Optional single-character `-s` alias.\n    description: string?  -- Human-readable text shown in help output.\n) → ()",
          "owner": "Parser",
          "desc": "Registers a boolean flag (`true` when present, `false` when absent).\n\nFlags can be combined in short form: `-vh` sets both `-v` and `-h`.\n",
          "tags": [],
          "name": "addFlag",
          "return_str": "",
          "function_type": "Method",
          "errors": [
            {
              "desc": "Throws if the long or short name conflicts with an existing flag or option. "
            }
          ],
          "returns": [],
          "params": [
            {
              "lua_type": "string",
              "name": "longName",
              "desc": "The `--long` name (without dashes)."
            },
            {
              "lua_type": "string?",
              "name": "shortName",
              "desc": "Optional single-character `-s` alias."
            },
            {
              "lua_type": "string?",
              "name": "description",
              "desc": "Human-readable text shown in help output."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 328
          },
          "is_method": true,
          "signature": "Parser:addOption(\n    longName: string,  -- The `--long` name (without dashes).\n    shortName: string?,  -- Optional single-character `-s` alias.\n    type: \"string\" | \"number\",  -- `\"string\"` or `\"number\"` - numeric values are coerced automatically.\n    default: any?,  -- Default value when omitted. Implies optional when non-nil.\n    required: boolean?,  -- Whether the option must be provided. Defaults to `true` unless a default is given.\n    description: string?,  -- Human-readable text shown in help output.\n    settings: { multiple: boolean?, arity: number? }?  -- Optional parser settings such as `multiple` and `arity`.\n) → ()",
          "owner": "Parser",
          "desc": "Registers a key-value option.\n\nOptions consume the next argument (or the `=`-separated value) as their\nvalue. In merged short form the last character is treated as the option\nand everything after it (or the next argument) is the value:\n`-vp 8080` sets `-v` (flag) and `-p 8080` (option).\n\nIf a `default` is provided the option is automatically optional.\nTo make an option optional with no default, pass `nil` for default\nand `false` for required.\n\n`settings.multiple = true` allows an option to be repeated and collects\nits values into an array. `settings.arity` controls how many values each\noccurrence consumes.\n",
          "tags": [],
          "name": "addOption",
          "return_str": "",
          "function_type": "Method",
          "errors": [
            {
              "desc": "Throws if the long or short name conflicts with an existing flag or option."
            },
            {
              "desc": "Throws if a default is provided for a required option. "
            }
          ],
          "returns": [],
          "params": [
            {
              "lua_type": "string",
              "name": "longName",
              "desc": "The `--long` name (without dashes)."
            },
            {
              "lua_type": "string?",
              "name": "shortName",
              "desc": "Optional single-character `-s` alias."
            },
            {
              "lua_type": "\"string\" | \"number\"",
              "name": "type",
              "desc": "`\"string\"` or `\"number\"` - numeric values are coerced automatically."
            },
            {
              "lua_type": "any?",
              "name": "default",
              "desc": "Default value when omitted. Implies optional when non-nil."
            },
            {
              "lua_type": "boolean?",
              "name": "required",
              "desc": "Whether the option must be provided. Defaults to `true` unless a default is given."
            },
            {
              "lua_type": "string?",
              "name": "description",
              "desc": "Human-readable text shown in help output."
            },
            {
              "lua_type": "{ multiple: boolean?, arity: number? }?",
              "name": "settings",
              "desc": "Optional parser settings such as `multiple` and `arity`."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 375
          },
          "is_method": true,
          "signature": "Parser:addMutuallyExclusive(names: { string }, required: boolean?) → ()",
          "owner": "Parser",
          "desc": "Registers a mutually exclusive group of flags/options by long name.\n\nAt most one name in the group may be present during parsing. If `required`\nis `true`, exactly one member must be present.\n",
          "tags": [],
          "name": "addMutuallyExclusive",
          "return_str": "",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "{ string }",
              "name": "names",
              "desc": ""
            },
            {
              "lua_type": "boolean?",
              "name": "required",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 527
          },
          "is_method": true,
          "signature": "Parser:getCompletionCandidates(arguments: { string }?) → { string }",
          "owner": "Parser",
          "desc": "Returns shell completion candidates for the parser after consuming the\nprovided fully-typed arguments.\n\nThis is intentionally conservative: if the parser is currently waiting\nfor an option value it returns no candidates so the shell can fall back\nto filename or custom value completion.\n",
          "tags": [],
          "name": "getCompletionCandidates",
          "return_str": "{ string }",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "{ string }",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "{ string }?",
              "name": "arguments",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 949
          },
          "is_method": true,
          "signature": "Parser:generateCompletion(shell: \"bash\" | \"zsh\" | \"fish\" | \"powershell\", programName: string?) → string",
          "owner": "Parser",
          "desc": "Generates a shell completion script for this parser.\n\nSupports `\"bash\"`, `\"zsh\"`, `\"fish\"`, and `\"powershell\"`, and generates\nsubcommand-aware completions for commands and flags/options.\n",
          "tags": [],
          "name": "generateCompletion",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "\"bash\" | \"zsh\" | \"fish\" | \"powershell\"",
              "name": "shell",
              "desc": ""
            },
            {
              "lua_type": "string?",
              "name": "programName",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 979
          },
          "is_method": true,
          "signature": "Parser:generateHelp() → (\n    string  -- The formatted help text. \n)",
          "owner": "Parser",
          "desc": "Builds a human-readable help string from the parser's current\nconfiguration, including usage line, description, arguments,\nsubcommands, flags, options, and epilog.\n",
          "tags": [],
          "name": "generateHelp",
          "return_str": "string",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The formatted help text. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 1080
          },
          "is_method": true,
          "signature": "Parser:parse(\n    arguments: { string }?  -- Argument list to parse. Defaults to `os.cliargs()`.\n) → (\n    { [string]: any }  -- A table mapping argument names to their parsed values.\n)",
          "owner": "Parser",
          "desc": "Parses command-line arguments against this parser's configuration.\n\nParsing supports:\n- **Positional arguments** - consumed left-to-right.\n- **Long flags / options** - `--verbose`, `--port 8080`, `--port=8080`.\n- **Short flags / options** - `-v`, `-p 8080`.\n- **Merged short flags** - `-vh` expands to `-v -h`.\n  The last character may be an option: `-vp 8080` -> `-v` flag + `-p 8080` option.\n- **Subcommands** - remaining arguments are delegated to the\n  subcommand's parser and its result is stored under the subcommand name.\n\nIf the built-in `--help` flag is set, the help handler is invoked\n**before** required-argument validation, so `mytool --help` always works.\n",
          "tags": [],
          "name": "parse",
          "return_str": "{ [string]: any }",
          "function_type": "Method",
          "errors": [
            {
              "desc": "Throws on unknown flags/options, missing required arguments, or type coercion failures. "
            }
          ],
          "returns": [
            {
              "lua_type": "{ [string]: any }",
              "desc": "A table mapping argument names to their parsed values."
            }
          ],
          "params": [
            {
              "lua_type": "{ string }?",
              "name": "arguments",
              "desc": "Argument list to parse. Defaults to `os.cliargs()`."
            }
          ]
        }
      ],
      "metamethods": [],
      "types": []
    }
  ]
}