A simple arguments utility
Project description
hargutil
A tool for dealing args.
Read Chinese version if possible.
请尽可能看中文版本。
Install
The package can be installed through pip (this is the recommended method)
pip install hargs
Or downloading the release from Pypi or Github
Usage
New
First, create a Hargs class:
hargs = Hargs(sys.argv)
Hargs.add()
To add some switches, use function Hargs.add(short:str, long:str, map: str)
Args instructions:
short like -o=output.txt
long like --input-file=input.txt
map For convincing of using. Depend by yourself.
Example:
hargs.add('v', 'version', 'v') \
.add('f', 'file', 'f') \
.add('o', 'output', 'o') \
.add('', 'force', 'ff') \
# ... ...
It's worth noticing that short and long can't be '' at the same time.
map can't be ''
Hargs.to_dict()
Then hargs can be transformed into dict:
hargs = hargs.to_dict()
Example:
./hargs.py -v -o=output.txt --force will turn into
{
'v': '',
'f': None,
'o': 'output.txt',
'ff': ''
}
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 Distribution
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 hargutil-1.1.3.tar.gz.
File metadata
- Download URL: hargutil-1.1.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c454afb66ebbc198e308a3f53e6648c1b271757a26238705acc1f332c2bf9eff
|
|
| MD5 |
ee99124228e5b5964a2e61951da62522
|
|
| BLAKE2b-256 |
ef4b22f177e87c66e3998777a0b88e6200d61fcf29df05b444fd37eec50e392e
|
File details
Details for the file hargutil-1.1.3-py3-none-any.whl.
File metadata
- Download URL: hargutil-1.1.3-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b56c7de941a946ab896828a63378fe777574fda6f56e8b69032bb870fefd745b
|
|
| MD5 |
ca480337f04f903f686406c490dc48cb
|
|
| BLAKE2b-256 |
acfd70d28f86853d032cc3f533f73efb6cdfabe962d382edb267d88e1cf1f6ca
|