Skip to main content

Command line argument parser for pythonic code

Project description

clappy

Command Line Argument Parser for pythonic code.

Simple example with clappy:

import clappy as cl

is_verbose = cl.parse("--verbose", "-v", is_flag=True)
log_level = cl.parse("--log_level", defaut="warning") 

# set logger with them

You can easily get each result independently.

Equivalent script without clappy:

from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument("--verbose", "-v", action="store_true")
parser.add_argument("--log_level", default="warning")
args = parser.parse_args()
is_verbose = args.verbose
log_level = args.log_level

# set logger with them

Script with clappy is obviously more readable and writable.

Clappy is especially strong when you have multiple modules requiring commandline argument. You usually must give parser to other modules one by one till the parser gets all arguments. After you register all arguments and parse result, you must allocate each result to each module.

Clappy frees you from such tiresome process by individual parsing.

Install

pip install clappy

How to use

clappy is a wrapper of argparse. You can give arguments for clappy same as argparse. Reference of argparse is here.

Just call clappy.parse(*args, **kwargs) as if argparse.ArgumentParser().add_argument(*args, **kwargs). Both methods accept same args.

If you want to generate help automatically, call clappy.create_help(). It must be done after all arguments got parsed.

To give some args for ArgumentParser constructor: initialize parser with clappy.initialize_parser(*args, **kwargs).

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clappy-0.2.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file clappy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: clappy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for clappy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78d66b1f0843b2a4b546c20dd107d7de8791051a3d431d92115be5f43185df47
MD5 9863e1c23460970027088f4b978bef86
BLAKE2b-256 b3f6e39e37b6320d2e5ae64e0902b310f93954eab08ecf76ae49da89e6edc9d9

See more details on using hashes here.

Supported by

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