# sphobjinv.cli.parser

`sphobjinv` CLI parser definition module.

`sphobjinv` is a toolkit for manipulation and inspection of Sphinx objects.inv files.

Author

  Brian Skinn (brian.skinn@gmail.com)

File Created

  15 Nov 2020

Copyright

  (c) Brian Skinn 2016-2025

Source Repository

  https://github.com/bskinn/sphobjinv

Documentation

  https://sphobjinv.readthedocs.io/en/stable

License

  Code: MIT License

  Docs & Docstrings: CC BY 4.0 International License

  See LICENSE.txt for full license terms.

Members

class PrsConst

  Container for CLI parser constants.

  ALL = 'all'

    Optional argument name for use with the `SUGGEST` subparser, indicating to print all returned objects, regardless of the number returned, without asking for confirmation

  CONTRACT = 'contract'

    Optional argument name for use with the `CONVERT` subparser, indicating to contract URIs and display names to abbreviated forms in the generated output file

  CONVERT = 'convert'

    Subparser name for inventory file conversions; stored in `SUBPARSER_NAME` when selected

  DEF_BASENAME = 'objects'

    Default base name for an unspecified `OUTFILE`

  DEF_OUT_EXT = {'json': '.json', 'plain': '.txt', 'zlib': '.inv'}

    Default extensions for an unspecified `OUTFILE`

  DEF_THRESH = 75

    Default match threshold for `sphobjinv suggest --thresh`

  EXPAND = 'expand'

    Optional argument name for use with the `CONVERT` subparser, indicating to expand URI and display name abbreviations in the generated output file

  FOUND_URL = 'found_url'

    Dict key for URL at which an inventory was actually found

  HELP_CONV_EXTS = "'.inv/.txt/.json'"

    Help text for default extensions for the various conversion types

  HELP_CO_PARSER = 'Convert intersphinx inventory to zlib-compressed, plaintext, or JSON formats.'

    Help text for the `CONVERT` subparser

  HELP_SU_PARSER = 'Fuzzy-search intersphinx inventory for desired object(s).'

    Help text for the `SUGGEST` subparser

  INDEX = 'index'

    Optional argument name for use with the `SUGGEST` subparser, indicating to print the location index of each returned object within `INFILE` along with the object domain/role/name (may be specified with `SCORE`)

  INFILE = 'infile'

    Required positional argument name for use with both `CONVERT` and `SUGGEST` subparsers, holding the path (or URL, if `URL` is specified) to the input file

  JSON = 'json'

    Argument value for `CONVERT` `MODE`, to output an inventory as JSON

  MODE = 'mode'

    Positional argument name for use with `CONVERT` subparser, indicating output file format (`ZLIB`, `PLAIN` or `JSON`)

  OUTFILE = 'outfile'

    Optional positional argument name for use with the `CONVERT` subparser, holding the path to the output file (`DEF_BASENAME` and the appropriate item from `DEF_OUT_EXT` are used if this argument is not provided)

  OVERWRITE = 'overwrite'

    Optional argument name for use with the `CONVERT` subparser, indicating to overwrite any existing output file without prompting

  PAGINATE = 'paginate'

    Optional argument name for use with the `SUGGEST` subparser, indicating to paginate the suggest subcommand results

  PLAIN = 'plain'

    Argument value for `CONVERT` `MODE`, to output a plaintext inventory

  QUIET = 'quiet'

    Optional argument name for use with the `CONVERT` subparser, indicating to suppress console output

  SCORE = 'score'

    Optional argument name for use with the `SUGGEST` subparser, indicating to print the `fuzzywuzzy` score of each returned object within `INFILE` along with the object domain/role/name (may be specified with `INDEX`)

  SEARCH = 'search'

    Positional argument name for use with the `SUGGEST` subparser, holding the search term for `fuzzywuzzy` text matching

  SUBPARSER_NAME = 'sprs_name'

    Param for storing subparser name (`CONVERT` or `SUGGEST`)

  SUGGEST = 'suggest'

    Subparser name for inventory object suggestions; stored in `SUBPARSER_NAME` when selected

  SUGGEST_CONFIRM_LENGTH = 30

    Number of returned objects from a `SUGGEST` subparser invocation above which user will be prompted for confirmation to print the results (unless `ALL` is specified)

  THRESH = 'thresh'

    Optional argument name for use with the `SUGGEST` subparser, taking the minimum desired `fuzzywuzzy` match quality as one required argument

  URL = 'url'

    Optional argument name for use with both `CONVERT` and `SUGGEST` subparsers, indicating that `INFILE` is to be treated as a URL rather than a local file path

  VERSION = 'version'

    Optional argument name for use with the base argument parser, to show version &c. info, and exit

  VER_TXT = '\nsphobjinv v2.3.1.3\n\nCopyright (c) Brian Skinn 2016-2025\nLicense: The MIT License\n\nBug reports & feature requests: https://github.com/bskinn/sphobjinv\nDocumentation: https://sphobjinv.readthedocs.io\n'

    Version &c. output blurb

  ZLIB = 'zlib'

    Argument value for `CONVERT` `MODE`, to output a `zlib`-compressed inventory

getparser()

  Generate argument parser.

  Returns:

    prs – `ArgumentParser` – Parser for commandline usage of sphobjinv