This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature complete] A simple argument parser for Python
License
maandree/python-arg
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A simple argument parser for Python Example usage: import sys import arg def usage(): print('usage: %s [-v value] [-xy]' % sys.argv[0], file = sys.stderr) sys.exit(1) xflag = False yflag = False vflag = None parser = arg.Parser(usage = usage) for c in parser.flags: if c == 'x': xflag = True elif c == 'y': yflag = True elif c == 'v': vflag = parser.arg else: usage() Supports: Short flags without arguments Short flags with optionally attached arguments Joined short flags Long flags with optional arguments Long flags with mandatory arguments Long flags with mandatory attached arguments Long flags with mandatory detached arguments Long flags with without arguments Long flags with only one dash Flags not starting with a dash Numeral flags Stop parsing flags at -- Mixing flags and arguments Stop parsing flags at first argument Returning -- as an argument Not returning -- as an argument
About
[Feature complete] A simple argument parser for Python
Topics
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published