Need help with args?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kennethreitz-archive
206 Stars 22 Forks BSD 2-Clause "Simplified" License 41 Commits 6 Opened issues

Description

Argument Parsing for Humans™

Services available

!
?

Need anything else?

Contributors list

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) print 'Assignments detected: ' + str(args.assignments)

No arguments::

$ tool
Arguments passed in: []
Flags detected: 
Files detected: []
NOT files detected: 
Grouped Arguments: OrderedDict([('_', )])
Assignments detected: OrderedDict()

A few arguments::

$ tool -s yes no --number=one --letter a b c --number=two
Arguments passed in: ['-s', 'yes', 'no', '--number=one', '--letter', 'a', 'b', 'c', '--number=two']
Flags detected: 
Files detected: []
NOT files detected: 
Grouped Arguments: OrderedDict([('_', ), ('-s', ), ('--number=one', ), ('--letter', ), ('--number=two', )])
Assignments detected: OrderedDict([('--number', )])

A few expanded file arguments::

$ tool *.py
Arguments passed in: ['args.py', 'setup.py', 'tests.py']
Flags detected: 
Files detected: ['args.py', 'setup.py', 'tests.py']
NOT files detected: 
Grouped Arguments: OrderedDict([('_', )])
Assignments detected: OrderedDict()

A few non-expanded file arguments::

$ tool '*.py'
Arguments passed in: ['*.py']
Flags detected: 
Files detected: ['args.py', 'setup.py', 'tests.py']
NOT files detected: 
Grouped Arguments: OrderedDict([('_', )])
Assignments detected: OrderedDict()

A few mixed files/flags/arguments::

Arguments passed in: ['*.py', '--letter', 'a', 'b', 'c', '-s', '/home/example/.example', '--number=one', '--number=two']
Flags detected: 
Files detected: ['setup.py', 'args.py', 'tool.py', 'tests.py', '/home/example/.example/two', '/home/example/.example/one']
NOT files detected: 
Grouped Arguments: OrderedDict([('_', ), ('--letter', ), ('-s', ), ('--number=one', ), ('--number=two', )])
Assignments detected: OrderedDict([('--number', )])

Installation

Installation is simple with pip::

$ pip install args

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.