This repository was archived by the owner on Oct 6, 2024. 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
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repo has been moved to Codeberg and may be out of date on GitHub. Canonical repo: https://codeberg.org/maandree/python-arg 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