Skip to main content

Inspection based parser based on argparse.

Project description

python-argufy

license build codecov

Overview

Inspection based parser built on argparse. Build complex CLI interfaces by writing more code-complete applications.

Motivation

Argufy is designed to be an alternative to decorator based parsers such as Click. Decorators have limitations that prevent effective use of inspection without drawbacks. This parser easilly allows a CLI to be created with minimal effort while enabling inspection.

Install

pip install argufy

Create CLI module with a command and an argument.

def example(argument: bool = False):
    """Provide an example command.

    Parameters
    ----------
    argument: bool, optional
        Provide an example argument.

    """
    if argument:
        print('This is a true argument')
    else:
        print('This is a false argument')

Create a parser

from argufy import Parser
from . import cli

def main():
    """Do main function for CLI."""
    parser = Parser()
    parser.add_commands(cli)
    parser.dispatch()

if __name__ == '__main__':
    main()

Example help message.

$ command --help
usage: command [-h] {example} ...

positional arguments:
  {example}
    example             Provide an example command.

optional arguments:
  -h, --help            show this help message and exit

Example command help message.

$ command example --help
usage: command [-h] [--argument ARGUMENT]

optional arguments:
  -h, --help           show this help message and exit
  --argument ARGUMENT  Provide an example argument.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

argufy-0.1.2b4.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

argufy-0.1.2b4-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file argufy-0.1.2b4.tar.gz.

File metadata

  • Download URL: argufy-0.1.2b4.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.11.9

File hashes

Hashes for argufy-0.1.2b4.tar.gz
Algorithm Hash digest
SHA256 83acea11240414390df0714bbc4bcb1f035425938fd1807eeeeaca92bde7d9cf
MD5 e2eec5e56829fb3ff1e8f0c736d1b3d3
BLAKE2b-256 2b8ec844bdc60de40a71286f128cdce923fbabcd0b4350e1f79b94a7f813f096

See more details on using hashes here.

File details

Details for the file argufy-0.1.2b4-py3-none-any.whl.

File metadata

  • Download URL: argufy-0.1.2b4-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.11.9

File hashes

Hashes for argufy-0.1.2b4-py3-none-any.whl
Algorithm Hash digest
SHA256 dbac13e5d21065a9edc1255e453884064c3db40bb9bc5c953469350fb54216d9
MD5 eb12af646e648c671358ee26d9041c7a
BLAKE2b-256 23baabc8a127151d58393f4415b647e67523605f6d25bf62c29cda82f59ef5b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page