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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clappy-0.1.6-py3-none-any.whl.
File metadata
- Download URL: clappy-0.1.6-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce680840e8d812e5c4b133c5dd728e52ad0c1c74e66639a0495659a25d7c16fd
|
|
| MD5 |
3d53ba75c84898f31179ce38125f04d6
|
|
| BLAKE2b-256 |
cd53e92301f1404e9db752750e0df123c51ba4cb0dab6435bcea6857b344b917
|