Skip to main content

A simple command line argument parsing library

Project description

Klarg

A Kommand Line ARGument parsing library.

Klarg is a small and simple command line argument parsing library built with no 3rd party dependencies.

Why use klarg?

Simple syntax

It abstracts all the complexities away so that you can focus on developing the appication itself.

# example.py
import klarg
name = klarg.get_str("name")
print(f"Your name is: {name}")

# python example.py --name klarg
# Your name is: klarg

Easy configuring

It makes use of the powerful dictionary data type to make configuring klarg a breeze.

# example.py
import klarg

# Replace -- with +
CONFIG["long_prefix"] = "+"
name = klarg.get_str("name")
print(f"Your name is: {name}")

# python example.py +name klarg
# Your name is klarg

Simple data types

Klarg only returns basic data types such as int, float, str and bool. This means no converting from strings to integers, or to booleans, klarg already does that.

# example.py
import klarg

is_there = klarg.get_bool("is-there")
if is_there:
    print("I am here")
else:
    print("I am not here")

# python example.py --is-there
# I am here

No 3rd party dependencies

Klarg was specifically designed not to include any external dependencies, helping to keep the size small.

Installation

Installing klarg is incredibly simple, just type in

pip install klarg

How to use?

# example.py
import klarg
klarg_is_cool = klargs.get_bool(long="klarg-cool", short="k")
klargs.on_help(do_something)

if (klarg_is_cool):
    print("Oh, my, klarg is cool.")

# python example.py --klarg-cool
# Oh, my, klarg is cool.

# python example.py -k
# Oh, my, klarg is cool.

Check out the Documentation for more.

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

klarg-1.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

klarg-1.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file klarg-1.1.0.tar.gz.

File metadata

  • Download URL: klarg-1.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for klarg-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a09956d7054162e5646397001117bffe9eda95240f9d9713ea91ed50f460c572
MD5 f15d0395f696a918a90bd0ce2250cdf8
BLAKE2b-256 718196e3c9072365b65f721931a2a7cb941ef898390c663ee8d788b3d02fe543

See more details on using hashes here.

File details

Details for the file klarg-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: klarg-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for klarg-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9077e76dbdb57eafc2606069c8b8a2e9fd2ff92c5bcc28ac6177aca7af5a1be8
MD5 2f326a6884ef5986edfe3061d878d5f1
BLAKE2b-256 34cacd34543009daf0a04e88f43ad28525a2fb1a2dac47a1bfdad1778d5a9882

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page