Giter Site home page Giter Site logo

easy_arg_parse's Introduction

easy_arg_parse

I think a better alternative to argparse

installation

either git pull... then python setup.py install or pip install easy_arg_parse

usage example

# program_that_needs_arguments.py
from easy_arg_parse import easy_arg_parse

if __name__ == '__main__':
    eap = easy_arg_parse.EasyArgParse\
            (
                defined_args=
                {
                    'input_dir':
                        {
                            'optional': False,
                            'help_text': "Directory containing jpgs"
                        },
                    'output_dir':
                        {
                            'optional': False,
                            'help_text': "The output directory"
                        },
                    'resize_ratio':
                        {
                            'optional': False,
                            'help_text': "How much you want to shrink the jpg as a fraction of 1 i.e. 0.75"
                        },
                    'resize_quality':
                        {
                            'optional': True,
                            "help_text": "The quality level of the saved jpg as a fraction of 1 i.e. 0.9"
                        }
                },
                aliases={
                    "i": "input_dir",
                    "in": "input_dir",
                    "o": "output_dir",
                    "out": "output_dir",
                    "ratio": "resize_ration",
                    "r": "resize_ratio",
                    "q": "resize_quality"
                }
            )
    args_dict = eap.parse()
    print("args:")
    print(args_dict) # Woah! it's a dict with all of the arguments supplied!!
    # Woah types have been inferred (i.e. str, int, float, bool)
    # Woah, a reasonable help has been printed out if mandatory arguments are missing or the help switch is used!
    ```

easy_arg_parse's People

Watchers

James Cloos avatar  avatar  avatar

Forkers

pombredanne

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.