https://github.com/casperdcl/argopt

convert docopt to argparse

https://github.com/casperdcl/argopt

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary

Keywords

cli developer-tools docopt hacktoberfest hacktoberfest2021 python
Last synced: 5 months ago · JSON representation

Repository

convert docopt to argparse

Basic Info
Statistics
  • Stars: 23
  • Watchers: 3
  • Forks: 2
  • Open Issues: 5
  • Releases: 15
Topics
cli developer-tools docopt hacktoberfest hacktoberfest2021 python
Created almost 10 years ago · Last pushed 11 months ago
Metadata Files
Readme Funding Codeowners

README.rst

argopt
======

doc to ``argparse`` driven by ``docopt``

|Py-Versions| |PyPI| |Conda-Forge|

|Build-Status| |Coverage-Status| |Branch-Coverage-Status| |Codacy-Grade| |Libraries-Rank| |PyPI-Downloads|

|LICENCE| |OpenHub-Status| |Gift-Casper|

Define your command line interface (CLI) from a docstring (rather than the
other way around). Because it's easy. It's quick. Painless. Then focus on
what's actually important - using the arguments in the rest of your program.

The problem is that this is not always flexible. Still need all the features of
`argparse`? Now have the best of both worlds... all the extension such as
`shtab `__ or
`Gooey `__ but with the simple syntax of
`docopt `__.

------------------------------------------

.. contents:: Table of contents
   :backlinks: top
   :local:


Installation
------------

Latest PyPI stable release
~~~~~~~~~~~~~~~~~~~~~~~~~~

|PyPI| |PyPI-Downloads| |Libraries-Dependents|

.. code:: sh

    pip install argopt

Latest development release on GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

|GitHub-Status| |GitHub-Stars| |GitHub-Commits| |GitHub-Forks| |GitHub-Updated|

Pull and install:

.. code:: sh

    pip install "git+https://github.com/casperdcl/argopt.git@master#egg=argopt"

Latest Conda release
~~~~~~~~~~~~~~~~~~~~

|Conda-Forge|

.. code:: sh

    conda install -c conda-forge argopt


Changelog
---------

The list of all changes is available on the Releases page: |GitHub-Status|.


Usage
-----

Standard `docopt `__ docstring syntax applies.
Additionally, some improvements and enhancements are supported, such as type
checking and default positional arguments.

.. code:: python

    '''Example programme description.
    You should be able to do
        args = argopt(__doc__).parse_args()
    instead of
        args = docopt(__doc__)

    Usage:
        test.py [options]  [...]

    Arguments:
                           A file.
        --anarg=           Description here [default: 1e3:int].
        -p PAT, --patts PAT   Or [default: None:file].
        --bar=             Another [default: something] should
                              auto-wrap something in quotes and assume str.
        -f, --force           Force.
    '''
    from argopt import argopt
    __version__ = "0.1.2-3.4"


    parser = argopt(__doc__, version=__version__)
    args = parser.parse_args()
    if args.force:
        print(args)
    else:
        print(args.x)

For comparison, the `docopt` equivalent would be:

.. code:: python

    '''Example programme description.

    Usage:
        test.py [options]  [...]

    Arguments:
                           A file.
        --anarg=           int, Description here [default: 1e3].
        -p PAT, --patts PAT   file, Or (default: None).
        --bar=             str, Another [default: something] should
                              assume str like everything else.
        -f, --force           Force.
        -h, --help            Show this help message and exit.
        -v, --version         Show program's version number and exit.

    '''
    from docopt import docopt
    __version__ = "0.1.2-3.4"


    args = docopt(__doc__, version=__version__)
    args["--anarg"] = int(eval(args["--anarg"]))
    if args["--patts"]:
        args["--patts"] = open(args["--patts"])
    if args["--force"]:
        print(args)
    else:
        print(args[""])

Advanced usage and examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~

See the `examples `__
folder.


Documentation
-------------

|Py-Versions| |README-Hits|

.. code:: python

    def argopt(doc='', argparser=ArgumentParser,
               formatter_class=RawDescriptionHelpFormatter,
               logLevel=logging.NOTSET, **_kwargs):
      """
      Note that `docopt` supports neither type specifiers nor default
      positional arguments. We support both here.

      Parameters
      ----------
      doc  : docopt compatible, with optional type specifiers
          [default: '':str]
      argparser  : Argument parser class [default: argparse.ArgumentParser]
      version  : Version string [default: None:str]
      formatter_class  : [default: argparse.RawDescriptionHelpFormatter]
      logLevel  : [default: logging.NOTSET]
      _kwargs  : any `argparser` initialiser arguments
          N.B.: `prog`, `description`, and `epilog` are automatically
          inferred if not `None`

      Returns
      -------
      out  : argparser object (default: argparse.ArgumentParser)

      Usage
      -----
      Extension syntax example: [default: 1e3:int].

      You should be able to do
          parser = argopt(__doc__)
          args   = parser.parse_args()
      instead of
          args = docopt(__doc__)

      TODO
      ----
      add_argument_group
      add_mutually_exclusive_group
      (better) subparser support
      (docopt extension) action choices
      (docopt extension) action count
      """


Contributions
-------------

|GitHub-Commits| |GitHub-Issues| |GitHub-PRs| |OpenHub-Status|

All source code is hosted on `GitHub `__.
Contributions are welcome.


LICENCE
-------

Open Source (OSI approved): |LICENCE|


Authors
-------

|OpenHub-Status|

- Casper da Costa-Luis (`casperdcl `__ |Gift-Casper|)

We are grateful for all |GitHub-Contributions|.

|README-Hits|

.. |Build-Status| image:: https://img.shields.io/github/actions/workflow/status/casperdcl/argopt/test.yml?branch=master&label=argopt&logo=GitHub
   :target: https://github.com/casperdcl/argopt/actions/workflows/test.yml
.. |Coverage-Status| image:: https://img.shields.io/coveralls/github/casperdcl/argopt/master?logo=coveralls
   :target: https://coveralls.io/github/casperdcl/argopt
.. |Branch-Coverage-Status| image:: https://codecov.io/gh/casperdcl/argopt/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/casperdcl/argopt
.. |Codacy-Grade| image:: https://api.codacy.com/project/badge/Grade/5282d52c142d4c6ea24f978b03981c6f
   :target: https://app.codacy.com/gh/casperdcl/argopt
.. |GitHub-Status| image:: https://img.shields.io/github/tag/casperdcl/argopt.svg?maxAge=86400&logo=github
   :target: https://github.com/casperdcl/argopt/releases
.. |GitHub-Forks| image:: https://img.shields.io/github/forks/casperdcl/argopt.svg?logo=github
   :target: https://github.com/casperdcl/argopt/network
.. |GitHub-Stars| image:: https://img.shields.io/github/stars/casperdcl/argopt.svg?logo=github
   :target: https://github.com/casperdcl/argopt/stargazers
.. |GitHub-Commits| image:: https://img.shields.io/github/commit-activity/y/casperdcl/argopt?label=commits&logo=git
   :target: https://github.com/casperdcl/argopt/graphs/commit-activity
.. |GitHub-Issues| image:: https://img.shields.io/github/issues-closed/casperdcl/argopt.svg?logo=github
   :target: https://github.com/casperdcl/argopt/issues
.. |GitHub-PRs| image:: https://img.shields.io/github/issues-pr-closed/casperdcl/argopt.svg?logo=github
   :target: https://github.com/casperdcl/argopt/pulls
.. |GitHub-Contributions| image:: https://img.shields.io/github/contributors/casperdcl/argopt.svg?logo=github
   :target: https://github.com/casperdcl/argopt/graphs/contributors
.. |GitHub-Updated| image:: https://img.shields.io/github/last-commit/casperdcl/argopt?label=pushed&logo=github
   :target: https://github.com/casperdcl/argopt/pulse
.. |Gift-Casper| image:: https://img.shields.io/badge/gift-donate-dc10ff.svg?logo=Contactless%20Payment
   :target: https://caspersci.uk.to/donate
.. |PyPI| image:: https://img.shields.io/pypi/v/argopt.svg?logo=PyPI&logoColor=white
   :target: https://pypi.org/project/argopt
.. |PyPI-Downloads| image:: https://img.shields.io/pypi/dm/argopt.svg?label=pypi%20downloads&logo=DocuSign
   :target: https://pypi.org/project/argopt
.. |Py-Versions| image:: https://img.shields.io/pypi/pyversions/argopt.svg?logo=python&logoColor=white
   :target: https://pypi.org/project/argopt
.. |Conda-Forge| image:: https://img.shields.io/conda/v/conda-forge/argopt.svg?label=conda-forge&logo=conda-forge
   :target: https://anaconda.org/conda-forge/argopt
.. |Libraries-Rank| image:: https://img.shields.io/librariesio/sourcerank/pypi/argopt.svg?color=green&logo=koding
   :target: https://libraries.io/pypi/argopt
.. |Libraries-Dependents| image:: https://img.shields.io/librariesio/dependent-repos/pypi/argopt.svg?logo=koding
    :target: https://github.com/casperdcl/argopt/network/dependents
.. |OpenHub-Status| image:: https://www.openhub.net/p/arg-opt/widgets/project_thin_badge?format=gif
   :target: https://www.openhub.net/p/arg-opt?ref=Thin+badge
.. |LICENCE| image:: https://img.shields.io/pypi/l/argopt.svg?color=purple&logo=SPDX
   :target: https://raw.githubusercontent.com/casperdcl/argopt/master/LICENCE
.. |README-Hits| image:: https://cgi.cdcl.ml/hits?q=argopt&style=social&r=https://github.com/casperdcl/argopt
   :target: https://cgi.cdcl.ml/hits?q=argopt&a=plot&r=https://github.com/casperdcl/argopt&style=social

Owner

Open Core Software Consultant & Technical Product Manager; Computational Physicist; member of IEEE, IOP, & @python Software Foundation

GitHub Events

Total
  • Release event: 2
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 5
  • Push event: 8
  • Pull request review event: 2
  • Pull request event: 7
  • Fork event: 1
  • Create event: 3
Last Year
  • Release event: 2
  • Watch event: 2
  • Delete event: 1
  • Issue comment event: 5
  • Push event: 8
  • Pull request review event: 2
  • Pull request event: 7
  • Fork event: 1
  • Create event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 83
  • Total Committers: 1
  • Avg Commits per committer: 83.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Casper da Costa-Luis c****l@p****g 83
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 12
  • Total pull requests: 10
  • Average time to close issues: 5 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 9
  • Total pull request authors: 3
  • Average comments per issue: 2.5
  • Average comments per pull request: 1.1
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 4
  • Average time to close issues: N/A
  • Average time to close pull requests: about 8 hours
  • Issue authors: 0
  • Pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.75
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 1
Top Authors
Issue Authors
  • sjpb (3)
  • casperdcl (2)
  • jiangweiyao (1)
  • muellerk22 (1)
  • UplinkPhobia (1)
  • alphapapa (1)
  • ignatenkobrain (1)
  • Freed-Wu (1)
  • GhostofGoes (1)
Pull Request Authors
  • casperdcl (8)
  • vojtechtrefny (4)
  • pre-commit-ci[bot] (2)
Top Labels
Issue Labels
enhancement (3) question (2) bug (1) invalid (1)
Pull Request Labels
framework (7) bug (6) enhancement (4)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 9,855 last-month
  • Total dependent packages: 6
    (may contain duplicates)
  • Total dependent repositories: 24
    (may contain duplicates)
  • Total versions: 25
  • Total maintainers: 1
pypi.org: argopt

doc to argparse driven by docopt

  • Versions: 21
  • Dependent Packages: 4
  • Dependent Repositories: 20
  • Downloads: 9,855 Last month
Rankings
Dependent packages count: 1.8%
Dependent repos count: 3.3%
Downloads: 5.7%
Average: 8.9%
Stargazers count: 14.5%
Forks count: 19.1%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: argopt
  • Versions: 4
  • Dependent Packages: 2
  • Dependent Repositories: 4
Rankings
Dependent repos count: 16.1%
Dependent packages count: 19.6%
Average: 36.7%
Stargazers count: 51.8%
Forks count: 59.2%
Last synced: 6 months ago

Dependencies

.github/workflows/comment-bot.yml actions
  • actions/checkout v3 composite
  • actions/github-script v6 composite
.github/workflows/test.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • casperdcl/deploy-pypi v2 composite
  • reviewdog/action-setup v1 composite
pyproject.toml pypi
setup.py pypi