About
=====
Additional Python argparse types and actions.
Project homepage: https://github.com/eerimoq/argparse_addons
Installation
============
.. code-block:: text
$ pip install argparse_addons
Examples
========
Integer type
------------
The script. See `examples/integer.py`_ for the complete script.
.. code-block:: python
parser.add_argument('--min-max',
type=argparse_addons.Integer(0, 255))
parser.add_argument('--min',
type=argparse_addons.Integer(0, None))
parser.add_argument('--max',
type=argparse_addons.Integer(None, 255))
parser.add_argument('--any',
type=argparse_addons.Integer())
Error message for the ``--min-max`` argument.
.. code-block:: text
$ python3 examples/integer.py --min-max -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min-max: -1 is not in the range 0..255
Error message for the ``--min`` argument.
.. code-block:: text
$ python3 examples/integer.py --min -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min: -1 is not in the range 0..inf
Error message for the ``--max`` argument.
.. code-block:: text
$ python3 examples/integer.py --max 1000
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --max: 1000 is not in the range -inf..255
Error message for the ``--any`` argument.
.. code-block:: text
$ python3 examples/integer.py --any a
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --any: invalid integer value: 'a'
All values within allowed ranges.
.. code-block:: text
$ python3 examples/integer.py --min-max 47 --min 1000 --max -5 --any 1
--min-max: 47
--min: 1000
--max: -5
--any: 1
Contributing
============
#. Fork the repository.
#. Install prerequisites.
.. code-block:: text
pip install -r requirements.txt
#. Implement the new feature or bug fix.
#. Implement test case(s) to ensure that future changes do not break
legacy.
#. Run the tests.
.. code-block:: text
make test
#. Create a pull request.
.. _examples/integer.py: https://github.com/eerimoq/argparse_addons/blob/master/examples/integer.py
Raw data
{
"_id": null,
"home_page": "https://github.com/eerimoq/argparse_addons",
"name": "argparse-addons",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "argparse",
"author": "Erik Moqvist",
"author_email": "erik.moqvist@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9e/35/33ecca1cdbebc5397a77f66edbc20ab76265176f7e3511b7696008ad9038/argparse_addons-0.12.0.tar.gz",
"platform": null,
"description": "About\n=====\n\nAdditional Python argparse types and actions.\n\nProject homepage: https://github.com/eerimoq/argparse_addons\n\nInstallation\n============\n\n.. code-block:: text\n\n $ pip install argparse_addons\n\nExamples\n========\n\nInteger type\n------------\n\nThe script. See `examples/integer.py`_ for the complete script.\n\n.. code-block:: python\n\n parser.add_argument('--min-max',\n type=argparse_addons.Integer(0, 255))\n parser.add_argument('--min',\n type=argparse_addons.Integer(0, None))\n parser.add_argument('--max',\n type=argparse_addons.Integer(None, 255))\n parser.add_argument('--any',\n type=argparse_addons.Integer())\n\nError message for the ``--min-max`` argument.\n\n.. code-block:: text\n\n $ python3 examples/integer.py --min-max -1\n usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]\n integer.py: error: argument --min-max: -1 is not in the range 0..255\n\nError message for the ``--min`` argument.\n\n.. code-block:: text\n\n $ python3 examples/integer.py --min -1\n usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]\n integer.py: error: argument --min: -1 is not in the range 0..inf\n\nError message for the ``--max`` argument.\n\n.. code-block:: text\n\n $ python3 examples/integer.py --max 1000\n usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]\n integer.py: error: argument --max: 1000 is not in the range -inf..255\n\nError message for the ``--any`` argument.\n\n.. code-block:: text\n\n $ python3 examples/integer.py --any a\n usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]\n integer.py: error: argument --any: invalid integer value: 'a'\n\nAll values within allowed ranges.\n\n.. code-block:: text\n\n $ python3 examples/integer.py --min-max 47 --min 1000 --max -5 --any 1\n --min-max: 47\n --min: 1000\n --max: -5\n --any: 1\n\nContributing\n============\n\n#. Fork the repository.\n\n#. Install prerequisites.\n\n .. code-block:: text\n\n pip install -r requirements.txt\n\n#. Implement the new feature or bug fix.\n\n#. Implement test case(s) to ensure that future changes do not break\n legacy.\n\n#. Run the tests.\n\n .. code-block:: text\n\n make test\n\n#. Create a pull request.\n\n.. _examples/integer.py: https://github.com/eerimoq/argparse_addons/blob/master/examples/integer.py\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Additional argparse types and actions.",
"version": "0.12.0",
"project_urls": {
"Homepage": "https://github.com/eerimoq/argparse_addons"
},
"split_keywords": [
"argparse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c141629e70c4cb32c1ddb88de970cd174bbb43d8241c8e07bdffc62a8280297c",
"md5": "e3c9625605b88b62ea342a72e2d3d1cf",
"sha256": "48b70ecd719054fcb0d7e6f25a1fecc13607aac61d446e83f47d211b4ead0d61"
},
"downloads": -1,
"filename": "argparse_addons-0.12.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e3c9625605b88b62ea342a72e2d3d1cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3310,
"upload_time": "2023-01-29T15:52:12",
"upload_time_iso_8601": "2023-01-29T15:52:12.255093Z",
"url": "https://files.pythonhosted.org/packages/c1/41/629e70c4cb32c1ddb88de970cd174bbb43d8241c8e07bdffc62a8280297c/argparse_addons-0.12.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e3533ecca1cdbebc5397a77f66edbc20ab76265176f7e3511b7696008ad9038",
"md5": "65918f16a8ffee0069ac801814693b1b",
"sha256": "6322a0dcd706887e76308d23136d5b86da0eab75a282dc6496701d1210b460af"
},
"downloads": -1,
"filename": "argparse_addons-0.12.0.tar.gz",
"has_sig": false,
"md5_digest": "65918f16a8ffee0069ac801814693b1b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3780,
"upload_time": "2023-01-29T15:52:13",
"upload_time_iso_8601": "2023-01-29T15:52:13.862406Z",
"url": "https://files.pythonhosted.org/packages/9e/35/33ecca1cdbebc5397a77f66edbc20ab76265176f7e3511b7696008ad9038/argparse_addons-0.12.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-29 15:52:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eerimoq",
"github_project": "argparse_addons",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "argparse-addons"
}