argv-0.0.3
توضیحات
Simpler command line argument parsing
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | argv-0.0.3 |
| نام | argv |
| نسخه کتابخانه | 0.0.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Christopher Brown |
| ایمیل نویسنده | io@henrian.com |
| آدرس صفحه اصلی | https://github.com/chbrown/argv |
| آدرس اینترنتی | https://pypi.org/project/argv/ |
| مجوز | Copyright (c) 2013 Christopher Brown Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Simpler command line argument parsing
-------------------------------------
In the spirit of
```optimist`` <https://github.com/substack/node-optimist>`__: less
magic, more flexibility.
::
pi install argv
Quickstart
~~~~~~~~~~
Manual specification of arguments, no configuration:
::
import argv
argv.parse(['-i', 'input.txt', '-z', '--verbose'])
>>> {'i': 'input.txt', 'verbose': True, 'z': True}
Uses ``sys.argv`` (without the executable name) if no argument list is
given:
::
import sys
sys.argv
>>> ['/usr/local/bin/bottler', 'exec', 'prog.py', '--debug']
argv.parse()
>>> {'_': ['exec', 'prog.py'], 'debug': True}
Configuration:
::
parser = argv.Parser()
parser.add('action')
parser.add('target')
parser.add('-d', '--debug')
parser.parse(['exec', 'prog.py', '--debug'])
>>> {'action': 'exec', 'd': True, 'debug': True, 'target': 'prog.py'}
Testing
-------
Continuous integration:
|Travis CI Build Status|
Or run tests locally:
::
python setup.py test
Development
-----------
Terminology:
~~~~~~~~~~~~
- **flag**: a command line argument marked with a double dash or each
component of a group denoted by a single dash. E.g.,
- ``--verbose --logfile logs/app.txt`` has two flags: ``verbose``
and ``logfile``.
- ``-czf archive.tgz app/`` has three flags: ``c``, ``z``, and
``f``.
- **token**: a white-space separated command line item. E.g.,
- \`--input= --logfile logs/app.txt
Related libraries
-----------------
- https://github.com/docopt/docopt
- http://docs.python.org/2/library/argparse.html
- http://docs.python.org/2/library/optparse.html (Deprecated)
TODO: write about differences between this library (``argv``) and these
libraries, relative merits of each, opposing philosophies, etc.
License
-------
Copyright (c) 2013 Christopher Brown. `MIT
Licensed <https://raw.github.com/chbrown/argv/master/LICENSE>`__.
.. |Travis CI Build Status| image:: https://travis-ci.org/chbrown/argv.png?branch=master
:target: https://travis-ci.org/chbrown/argv
نحوه نصب
نصب پکیج whl argv-0.0.3:
pip install argv-0.0.3.whl
نصب پکیج tar.gz argv-0.0.3:
pip install argv-0.0.3.tar.gz