DEV Community

loading...

Introducing Klarg v0.0.1

Tomi Adenekan
It was my idea to use your idea
・1 min read

WARNING: A terrible sense of humor lies below

Introducing klarg v0.0.1. What is klarg? You might ask, and I might tell you that it is the result of bad decisions upon bad decisions. Or that it is a dead simple command line argument processing library. But that sounds like bragging.

Why should you use it? Well, if me making it is not enough, then just look this

# glorious_syntax.py
import klarg

klarg_is_cool = klarg.get_bool("klarg-cool")
if klarg_is_cool: # Not even considering another option 
    print("Klarg is cool")
Enter fullscreen mode Exit fullscreen mode

When we do this ...

python glorious_syntax.py --klarg-cool
Enter fullscreen mode Exit fullscreen mode

We get this

Klarg is cool
Enter fullscreen mode Exit fullscreen mode

You can also configure klarg as easily as you can make a cake. (which by the way, is very easily). I mean, just look at this

import klarg
klarg.config["long_prefix"] = "+"
Enter fullscreen mode Exit fullscreen mode

Just like that. We can call that taking advantage of python's awesomeness, just like that.

Also, there are no third party dependencies. wow, much rare

On a more serious note, check it out on github, it actually is a pretty cool project.

GitHub logo tominekan / klarg

A simple command line arguments parser

Klarg

Klarg Icon

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Simple data types

Klarg only returns basic data types such…

Discussion (2)

Collapse
giovanni3a profile image
Giovanni Amorim

Library simplicity convinced me to give it a try. Good sense of humor just made it my new favorite parsing lib.

Thank you for sharing!

Collapse
tominekan profile image
Tomi Adenekan Author

You`re welcome, Thanks for trying it out :)

Forem Open with the Forem app