Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hargutil-1.1.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hargutil-1.1.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for hargutil-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c454afb66ebbc198e308a3f53e6648c1b271757a26238705acc1f332c2bf9eff
MD5 ee99124228e5b5964a2e61951da62522
BLAKE2b-256 ef4b22f177e87c66e3998777a0b88e6200d61fcf29df05b444fd37eec50e392e

See more details on using hashes here.

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

Hashes for hargutil-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b56c7de941a946ab896828a63378fe777574fda6f56e8b69032bb870fefd745b
MD5 ca480337f04f903f686406c490dc48cb
BLAKE2b-256 acfd70d28f86853d032cc3f533f73efb6cdfabe962d382edb267d88e1cf1f6ca

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