Command line argument parser for pythonic code
Project description
Command Line Argument Parser for PYthonic code.
given_kwarg1 = clappy.parse("--kwarg1")
# do some stuff with given_kwarg1
given_kwarg2 = clappy.parse("--kwarg2")
Clappy allows you to parse command line arguments extremely easily and separatedly. There’s no need to manually add arguments to a parser beforehand, or reuse the parser or result in multiple scopes.
e.g. Script with clappy:
from clappy import parse
kwarg = parse("--kwarg")
parg = parse("fuga")
def set_logger():
logger_level = parse("--log_level")
logger.setLevel(logger_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, parg, logger_level = args.kwarg1, args.fuga, args.log_level
def set_level_on_logger(level):
logger.setLevel(level)
set_level_on_logger(logger_level)
Install
git clone https://github.com/yoko72/clappy Put the dir on path.
How to use
clappy is a wrapper of argparse. You can give arguments for clappy same as argparse. The reference of argparse is https://docs.python.org/ja/3/howto/argparse.html.
Just call clappy.parse(*args, **kwargs) as if argparse.ArgumentParser().add_argument(*args, **kwargs). To give some args for ArgumentParser constructor: clappy.Parser.set_args_for_parser_getter(*args, **kwargs) If you want to generate help automatically, call clappy.create_help(). It must be done after all arguments got parsed.
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.3-py3-none-any.whl.
File metadata
- Download URL: clappy-0.1.3-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 |
9b9e14008baf6fe492c6200df30d909831aaabe241c8f45469c2b5cefba47b05
|
|
| MD5 |
28dc4a75862454ec39f0f0ab9c8bbea4
|
|
| BLAKE2b-256 |
7df099007ce411a86b23a48c4baec0f8061954ecd50da074d75924737e3d4d85
|