Skip to main content

Installation

pip install decparse

Usage

Before with argeparse

import argparse

parser = argparse.ArgumentParser(
    prog='foo',
    description='Print bar',
    add_help=True
)
parser.add_argument(
    '--baz',
    action='store_true'
    help='Also print baz'
)
args = parser.parse_arguments()

print('bar')
if args.baz:
    print('baz')

Using decopts instead

from decopts import entrypoint, option

@entrypoint(
    prog='foo',
    description='Print bar',
    add_help=True
)
@option(
    '--baz',
    action='store_true'
    help='Also print baz'
)
def main():
    print('bar')
    if main.args.baz:
        print('baz')

main()

Adding subcommands

from decopts import entrypoint, option, action

@entrypoint(
    prog='foo',
    description='Print something',
    add_help=True
)
def main():
    return

@action(
    main,
    'foo',
    description='Print foo'
)
def foo():
    print('foo')

@action(
    main,
    'baz',
    description='Print baz'
)
def baz():
    print('baz')

main()

Metadata

Release files for decopts 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decopts 1.0.2
File Size Uploaded Provenance
decopts-1.0.2.tar.gz 4.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for decopts 1.0.2
File Interpreter ABI Platform
decopts-1.0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 8.0 kB

Release files / decopts-1.0.2.tar.gz

Download URL decopts-1.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2bfab155021adf9373c6b465afc3f1bff6b027c43634684ed3547fbe6e70135d
BLAKE2b-256 checksum
How to use checksums
91f9702abcaff841dfc03e52913cc2caad6b6e55fec32a98f16bffc7d386939a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / decopts-1.0.2-py2.py3-none-any.whl

Download URL decopts-1.0.2-py2.py3-none-any.whl
Size 3.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3fd566d06ce3c74495b3817c8401a5ebe857f2fed8080644016e04b2eff2ea6f
BLAKE2b-256 checksum
How to use checksums
091639e6cd69cc990d224887706da1425bd38cc30f6e66170ca473f6b58a8bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for decopts 1.0.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page