Code Monkey home page Code Monkey logo

args's Introduction

args

Argument Parsing for Humans.

Usage

Here's an example application:

import args

print 'Arguments passed in: ' + str(args.all)
print 'Flags detected: ' + str(args.flags)
print 'Files detected: ' + str(args.files)
print 'NOT files detected: ' + str(args.not_files)
print 'Grouped Arguments: ' + str(args.grouped)

No arguments:

$ tool
Arguments passed in: []
Flags detected: <args []>
Files detected: []
NOT Files detected: <args []>
Grouped Arguments: {'_': <args []>}

A few arguments:

$ tool -s this that --import this and that and this and that
Arguments passed in: ['-s', 'this', 'that', '--import', 'this', 'and', 'that', 'and', 'this', 'and', 'that']
Flags detected: <args ['-s', '--import'
Files detected: []
NOT Files detected: <args ['-s', 'this', 'that', '--import', 'this', 'and', 'that', 'and', 'this', 'and', 'that']>
Grouped Arguments: {'--import': <args ['this', 'and', 'that', 'and', 'this', 'and', 'that']>, '_': <args []>, '-s': <args ['this', 'that']>}

A few expanded file arguments:

$ tool *.py
Arguments passed in: ['args.py', 'setup.py']
Flags detected: <args []>
Files detected: ['args.py', 'setup.py']
NOT Files detected: <args []>
Grouped Arguments: {'_': <args ['args.py', 'setup.py']>}

A few non-expanded file arguments:

$ tool '*.py'
Arguments passed in: ['*.py']
Flags detected: <args []>
Files detected: ['args.py', 'setup.py']
NOT Files detected: <args []>
Grouped Arguments: {'_': <args ['*.py']>}

A few mixed files/flags/arguments:

$ tool '*.py' --test test face book -s ~/.ssh
Arguments passed in: ['*.py', '--test', 'test', 'face', 'book', '-s', '/Users/kreitz/.ssh']
Flags detected: <args ['--test', '-s']>
Files detected: ['args.py', 'setup.py', '/Users/kreitz/.ssh/id_rsa', '/Users/kreitz/.ssh/id_rsa.pub', '/Users/kreitz/.ssh/known_hosts']
NOT Files detected: <args ['--test', 'test', 'face', 'book', '-s']>
Grouped Arguments: {'--test': <args ['test', 'face', 'book']>, '_': <args ['*.py']>, '-s': <args ['/Users/kreitz/.ssh']>}

Installation

Installation is simple with pip:

$ pip install args

args's People

Contributors

bitprophet avatar jvirtanen avatar kracekumar avatar mahmoudhossam avatar reclosedev avatar

Stargazers

 avatar

Watchers

 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.