From b147896d43c04c79f66c0352eb53a99614d1a976 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 19 Oct 2017 16:14:58 +0200 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- README | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 README (limited to 'README') diff --git a/README b/README new file mode 100644 index 0000000..dd091db --- /dev/null +++ b/README @@ -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 -- cgit v1.2.3-70-g09d2