Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

maandree/python-arg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

No packages published