{"id":15658568,"url":"https://github.com/casperdcl/argopt","last_synced_at":"2026-02-26T07:47:39.640Z","repository":{"id":44546108,"uuid":"56628866","full_name":"casperdcl/argopt","owner":"casperdcl","description":"convert docopt to argparse","archived":false,"fork":false,"pushed_at":"2025-03-21T11:26:04.000Z","size":167,"stargazers_count":23,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T20:52:09.530Z","etag":null,"topics":["cli","developer-tools","docopt","hacktoberfest","hacktoberfest2021","python"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/argopt","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casperdcl.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"casperdcl","custom":"https://cdcl.ml/sponsor"}},"created_at":"2016-04-19T20:17:22.000Z","updated_at":"2025-03-21T11:22:40.000Z","dependencies_parsed_at":"2024-10-23T08:54:45.500Z","dependency_job_id":null,"html_url":"https://github.com/casperdcl/argopt","commit_stats":{"total_commits":83,"total_committers":1,"mean_commits":83.0,"dds":0.0,"last_synced_commit":"a2aeafe2436c3dbc8fb3cd8ea2308b0629789ba4"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casperdcl%2Fargopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casperdcl%2Fargopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casperdcl%2Fargopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casperdcl%2Fargopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casperdcl","download_url":"https://codeload.github.com/casperdcl/argopt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251801087,"owners_count":21645968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","developer-tools","docopt","hacktoberfest","hacktoberfest2021","python"],"created_at":"2024-10-03T13:12:56.835Z","updated_at":"2026-02-26T07:47:34.616Z","avatar_url":"https://github.com/casperdcl.png","language":"Python","funding_links":["https://github.com/sponsors/casperdcl","https://cdcl.ml/sponsor"],"categories":[],"sub_categories":[],"readme":"argopt\n======\n\ndoc to ``argparse`` driven by ``docopt``\n\n|Py-Versions| |PyPI| |Conda-Forge|\n\n|Build-Status| |Coverage-Status| |Branch-Coverage-Status| |Codacy-Grade| |Libraries-Rank| |PyPI-Downloads|\n\n|LICENCE| |OpenHub-Status| |Gift-Casper|\n\nDefine your command line interface (CLI) from a docstring (rather than the\nother way around). Because it's easy. It's quick. Painless. Then focus on\nwhat's actually important - using the arguments in the rest of your program.\n\nThe problem is that this is not always flexible. Still need all the features of\n`argparse`? Now have the best of both worlds... all the extension such as\n`shtab \u003chttps://github.com/iterative/shtab\u003e`__ or\n`Gooey \u003chttps://github.com/chriskiehl/Gooey\u003e`__ but with the simple syntax of\n`docopt \u003chttps://github.com/docopt/docopt\u003e`__.\n\n------------------------------------------\n\n.. contents:: Table of contents\n   :backlinks: top\n   :local:\n\n\nInstallation\n------------\n\nLatest PyPI stable release\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n|PyPI| |PyPI-Downloads| |Libraries-Dependents|\n\n.. code:: sh\n\n    pip install argopt\n\nLatest development release on GitHub\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n|GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated|\n\nPull and install:\n\n.. code:: sh\n\n    pip install \"git+https://github.com/casperdcl/argopt.git@master#egg=argopt\"\n\nLatest Conda release\n~~~~~~~~~~~~~~~~~~~~\n\n|Conda-Forge|\n\n.. code:: sh\n\n    conda install -c conda-forge argopt\n\n\nChangelog\n---------\n\nThe list of all changes is available on the Releases page: |GitHub-Status|.\n\n\nUsage\n-----\n\nStandard `docopt \u003chttps://github.com/docopt/docopt\u003e`__ docstring syntax applies.\nAdditionally, some improvements and enhancements are supported, such as type\nchecking and default positional arguments.\n\n.. code:: python\n\n    '''Example programme description.\n    You should be able to do\n        args = argopt(__doc__).parse_args()\n    instead of\n        args = docopt(__doc__)\n\n    Usage:\n        test.py [options] \u003cx\u003e [\u003cy\u003e...]\n\n    Arguments:\n        \u003cx\u003e                   A file.\n        --anarg=\u003ca\u003e           Description here [default: 1e3:int].\n        -p PAT, --patts PAT   Or [default: None:file].\n        --bar=\u003cb\u003e             Another [default: something] should\n                              auto-wrap something in quotes and assume str.\n        -f, --force           Force.\n    '''\n    from argopt import argopt\n    __version__ = \"0.1.2-3.4\"\n\n\n    parser = argopt(__doc__, version=__version__)\n    args = parser.parse_args()\n    if args.force:\n        print(args)\n    else:\n        print(args.x)\n\nFor comparison, the `docopt` equivalent would be:\n\n.. code:: python\n\n    '''Example programme description.\n\n    Usage:\n        test.py [options] \u003cx\u003e [\u003cy\u003e...]\n\n    Arguments:\n        \u003cx\u003e                   A file.\n        --anarg=\u003ca\u003e           int, Description here [default: 1e3].\n        -p PAT, --patts PAT   file, Or (default: None).\n        --bar=\u003cb\u003e             str, Another [default: something] should\n                              assume str like everything else.\n        -f, --force           Force.\n        -h, --help            Show this help message and exit.\n        -v, --version         Show program's version number and exit.\n\n    '''\n    from docopt import docopt\n    __version__ = \"0.1.2-3.4\"\n\n\n    args = docopt(__doc__, version=__version__)\n    args[\"--anarg\"] = int(eval(args[\"--anarg\"]))\n    if args[\"--patts\"]:\n        args[\"--patts\"] = open(args[\"--patts\"])\n    if args[\"--force\"]:\n        print(args)\n    else:\n        print(args[\"\u003cx\u003e\"])\n\nAdvanced usage and examples\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSee the `examples \u003chttps://github.com/casperdcl/argopt/tree/master/examples\u003e`__\nfolder.\n\n\nDocumentation\n-------------\n\n|Py-Versions| |README-Hits|\n\n.. code:: python\n\n    def argopt(doc='', argparser=ArgumentParser,\n               formatter_class=RawDescriptionHelpFormatter,\n               logLevel=logging.NOTSET, **_kwargs):\n      \"\"\"\n      Note that `docopt` supports neither type specifiers nor default\n      positional arguments. We support both here.\n\n      Parameters\n      ----------\n      doc  : docopt compatible, with optional type specifiers\n          [default: '':str]\n      argparser  : Argument parser class [default: argparse.ArgumentParser]\n      version  : Version string [default: None:str]\n      formatter_class  : [default: argparse.RawDescriptionHelpFormatter]\n      logLevel  : [default: logging.NOTSET]\n      _kwargs  : any `argparser` initialiser arguments\n          N.B.: `prog`, `description`, and `epilog` are automatically\n          inferred if not `None`\n\n      Returns\n      -------\n      out  : argparser object (default: argparse.ArgumentParser)\n\n      Usage\n      -----\n      Extension syntax example: [default: 1e3:int].\n\n      You should be able to do\n          parser = argopt(__doc__)\n          args   = parser.parse_args()\n      instead of\n          args = docopt(__doc__)\n\n      TODO\n      ----\n      add_argument_group\n      add_mutually_exclusive_group\n      (better) subparser support\n      (docopt extension) action choices\n      (docopt extension) action count\n      \"\"\"\n\n\nContributions\n-------------\n\n|GitHub-Commits| |GitHub-Issues| |GitHub-PRs| |OpenHub-Status|\n\nAll source code is hosted on `GitHub \u003chttps://github.com/casperdcl/argopt\u003e`__.\nContributions are welcome.\n\n\nLICENCE\n-------\n\nOpen Source (OSI approved): |LICENCE|\n\n\nAuthors\n-------\n\n|OpenHub-Status|\n\n- Casper da Costa-Luis (`casperdcl \u003chttps://github.com/casperdcl\u003e`__ |Gift-Casper|)\n\nWe are grateful for all |GitHub-Contributions|.\n\n|README-Hits|\n\n.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/casperdcl/argopt/test.yml?branch=master\u0026label=argopt\u0026logo=GitHub\n   :target: https://github.com/casperdcl/argopt/actions/workflows/test.yml\n.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/casperdcl/argopt/master?logo=coveralls\n   :target: https://coveralls.io/github/casperdcl/argopt\n.. |Branch-Coverage-Status| image:: https://codecov.io/gh/casperdcl/argopt/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/casperdcl/argopt\n.. |Codacy-Grade| image:: https://api.codacy.com/project/badge/Grade/5282d52c142d4c6ea24f978b03981c6f\n   :target: https://app.codacy.com/gh/casperdcl/argopt\n.. |GitHub-Status| image:: https://img.shields.io/github/tag/casperdcl/argopt.svg?maxAge=86400\u0026logo=github\n   :target: https://github.com/casperdcl/argopt/releases\n.. |GitHub-Forks| image:: https://img.shields.io/github/forks/casperdcl/argopt.svg?logo=github\n   :target: https://github.com/casperdcl/argopt/network\n.. |GitHub-Stars| image:: https://img.shields.io/github/stars/casperdcl/argopt.svg?logo=github\n   :target: https://github.com/casperdcl/argopt/stargazers\n.. |GitHub-Commits| image:: https://img.shields.io/github/commit-activity/y/casperdcl/argopt?label=commits\u0026logo=git\n   :target: https://github.com/casperdcl/argopt/graphs/commit-activity\n.. |GitHub-Issues| image:: https://img.shields.io/github/issues-closed/casperdcl/argopt.svg?logo=github\n   :target: https://github.com/casperdcl/argopt/issues\n.. |GitHub-PRs| image:: https://img.shields.io/github/issues-pr-closed/casperdcl/argopt.svg?logo=github\n   :target: https://github.com/casperdcl/argopt/pulls\n.. |GitHub-Contributions| image:: https://img.shields.io/github/contributors/casperdcl/argopt.svg?logo=github\n   :target: https://github.com/casperdcl/argopt/graphs/contributors\n.. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/casperdcl/argopt?label=pushed\u0026logo=github\n   :target: https://github.com/casperdcl/argopt/pulse\n.. |Gift-Casper| image:: https://img.shields.io/badge/gift-donate-dc10ff.svg?logo=Contactless%20Payment\n   :target: https://caspersci.uk.to/donate\n.. |PyPI| image:: https://img.shields.io/pypi/v/argopt.svg?logo=PyPI\u0026logoColor=white\n   :target: https://pypi.org/project/argopt\n.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/argopt.svg?label=pypi%20downloads\u0026logo=DocuSign\n   :target: https://pypi.org/project/argopt\n.. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/argopt.svg?logo=python\u0026logoColor=white\n   :target: https://pypi.org/project/argopt\n.. |Conda-Forge| image:: https://img.shields.io/conda/v/conda-forge/argopt.svg?label=conda-forge\u0026logo=conda-forge\n   :target: https://anaconda.org/conda-forge/argopt\n.. |Libraries-Rank| image:: https://img.shields.io/librariesio/sourcerank/pypi/argopt.svg?color=green\u0026logo=koding\n   :target: https://libraries.io/pypi/argopt\n.. |Libraries-Dependents| image:: https://img.shields.io/librariesio/dependent-repos/pypi/argopt.svg?logo=koding\n    :target: https://github.com/casperdcl/argopt/network/dependents\n.. |OpenHub-Status| image:: https://www.openhub.net/p/arg-opt/widgets/project_thin_badge?format=gif\n   :target: https://www.openhub.net/p/arg-opt?ref=Thin+badge\n.. |LICENCE| image:: https://img.shields.io/pypi/l/argopt.svg?color=purple\u0026logo=SPDX\n   :target: https://raw.githubusercontent.com/casperdcl/argopt/master/LICENCE\n.. |README-Hits| image:: https://cgi.cdcl.ml/hits?q=argopt\u0026style=social\u0026r=https://github.com/casperdcl/argopt\n   :target: https://cgi.cdcl.ml/hits?q=argopt\u0026a=plot\u0026r=https://github.com/casperdcl/argopt\u0026style=social\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasperdcl%2Fargopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasperdcl%2Fargopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasperdcl%2Fargopt/lists"}