Parsable is a lightweight decorator-based command line parser library. Parsable was written to be simpler than argparse, optparse, and argh.
Installation
Install from PyPI with pip
pip install parsable
Or just download parsable/__init__.py and add to your project.
Usage
Parsable uses just two pieces of syntax: a @parsable command decorator, and a parsable() dispatch function.
Import parsable.
from parsable import parsableDecorate functions you want parsed. Parsable inspects the function to decide how to parse arguments. Arguments without default values are parsed as strings. Default arguments of any type T can be parsed as long as T(some_string) can do the parsing.
@parsable def my_function(required_arg, optional_bool=True, optional_int=1): '''Help messages are not just a good idea, they are required''' # parsable automatically converts types based on default arguments: assert isinstance(required_arg, str) assert isinstance(optional_string, bool) assert isinstance(optional_int, int) # ... @parsable def do_stuff_with_files(*filenames, inplace=True): '''This does something to each file''' # ...Dispatch at the end of the script.
if __name__ == '__main__': parsable()Use your new script
$ python my_script.py my_function demo optional_int=5 ... # parsable replaces - with _ to make functions easier to read $ python my_script.py do-stuff-with-files *.py inplace=false ...
Advanced Usage
To show verbose information (commmand name and timing info), set the environment variable PARSABLE_VERBOSE=true.
If you use parsable for many modules in a package, you can collect them in your setup.py using parsable.find_entry_points().
from parsable import parsable
from setuptools import setup
setup(
name='my_package',
entry_points=parsable.find_entry_points('my_package'),
...
)
LICENSE
Parsable is dual-licensed under the MIT and GPL2 licenses.
Metadata
Release files for parsable 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| parsable-0.3.5.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| parsable-0.3.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / parsable-0.3.5.tar.gz
| Download URL | parsable-0.3.5.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1aca04740de93aad990e94a448fa6a6ce2bae6828a9e37335cdf011f6677b61
|
|
BLAKE2b-256 checksum How to use checksums |
6b002dd05fe1e04c2b03c185457bee0a2820e96aa5397b23abcc568a670a14eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / parsable-0.3.5-py3-none-any.whl
| Download URL | parsable-0.3.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
562a9f9411c9c871a5a38007a5f6570c5070aa51ccf3660d931bfe7eb89d079f
|
|
BLAKE2b-256 checksum How to use checksums |
e7a67ea8893fc008461ebea5384f30b29d2478efd86c96e1423ddf3b3b51e08a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for parsable 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.