diff options
author | Mattias Andrée <maandree@kth.se> | 2017-10-19 16:14:58 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-10-19 16:14:58 +0200 |
commit | b147896d43c04c79f66c0352eb53a99614d1a976 (patch) | |
tree | 0be1cf838463e6279f7074e003235298c5295a16 /README | |
download | python-arg-cec75f4d1a4de7949ff5225c72adb3ef5f2a5196.tar.gz python-arg-cec75f4d1a4de7949ff5225c72adb3ef5f2a5196.tar.bz2 python-arg-cec75f4d1a4de7949ff5225c72adb3ef5f2a5196.tar.xz |
First commit1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | README | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,42 @@ +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 |