Coder Social home page Coder Social logo

argparx's Introduction

#argparx x

I was really iritated how the argparse module works in python. Even replacements were no good, so I decided to write my own, for my own needs. ###What is argparx? argparx stands for argument parser x(tra) simple

###What are pros and cons of argparx?

Pros Cons
SIMPLE Can be a little tricky if you are not used to it
Light You cannot use multiple values as arguments (ex. '-y' and '--yes')
Can be used in every needed situation Can lack some of the features that argparse has

###How to use it? You need to start with initial setup

import argparx
parser = argparx.ArgParserX()

Then you have to take your arguments and setup your program definition

parser.take_args()
parser.program_def("Example")

Isn't that simple? Now you have your program definition and your args, so why don't we do some magic with our args and define some commands?

x = parser.object_arg("-x", helparg="single letter") #1
y = parser.object_arg("--yiks", helparg="multi letter") #2
f = parser.object_arg("-f", helparg="flag", flag=1) #3
z = parser.pos_arg("FILE", pos='start')#4
parser.help_arg() #5

First two are self-explanatory. 3rd is a flag. Flags always returns True or 1 (or False if not called). 4th is a positional argument, you define argname, which displays in '--help' prompt and a position (it can be 'start' or 'end'). 5th is initialization function of "--help" command - without it there's no "--help".

###TO-DO

  • Do multi-command support
  • Rewrite pos_arg() code

###Requirements

argparx's People

Contributors

reyuu avatar asdfmaciej avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.