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 using 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.1.7-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clappy-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e8e53cadc29101b51fa8e797af78e4ab437933d7f0262c02714e061535b75c61
MD5 de5eec5bd8eb6dbbc5d504e57f72b0c7
BLAKE2b-256 54e644d8be56947dbb6672a9fd9a5f419f621ec7e0bb15610fff8c06a5b58929

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