Skip to main content

Command line argument parser for pythonic code

Project description

Command Line Argument Parser for PYthonic code.

given_kwarg1 = clappy.parse("--kwarg1")

You can get each given command line argument easily. You don’t have to bother about handling parser anymore.

e.g. Script with clappy:

import clappy as cl

kwarg = cl.parse("--kwarg")
posi_args = cl.parse("fuga")

def set_logger():
    logger.setLevel(cl.parse("--log_level"))

set_logger()

Equivalent script without clappy:

from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument("--kwarg")
parser.add_argument("fuga")

def set_log_level_arg(parser):
    parser.add_argument("--log_level")

set_log_level_arg(parser)

args = parser.parse_args()
kwarg, posi_args, logger_level = args.kwarg1, args.fuga, args.log_level

def set_level_on_logger(level):
    logger.setLevel(level)

set_level_on_logger(logger_level)

When you accept arguments from command-line in multiple scopes, you must give the parser and result to another scope. Clappy will solve it!

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.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clappy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 589f6e53338a13e88c9d2b25e4bb85a93f080153b467712cc1587ccfcc65c85c
MD5 a2483c1e37bd43def12a17bde52e29c1
BLAKE2b-256 af628b36936a2610933a2189c32e6b505189c4e22be53609bdbfaf0e9e91fef3

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