]> arthur.barton.de Git - bup.git/commit
lib/options: Add an onabort argument to Options()
authorGabriel Filion <lelutin@gmail.com>
Tue, 27 Jul 2010 03:52:33 +0000 (23:52 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Tue, 27 Jul 2010 07:49:27 +0000 (03:49 -0400)
commit9a31a8cbd58f67899d1a340da61b598a11550e6f
tree63588998afb9350a7a8ec27cc75bc38b2d35e8ba
parenta6d0a19cf877cf0804bda4681eec4356cd3c5a38
lib/options: Add an onabort argument to Options()

Some times, we may want to parse a list of arguments and not have the
call to Options.parse() exit the program when it finds an unknown
argument.

Add an argument to the class' __init__ method that can be either a
function or a class (must be an exception class). If calling the
function or class constructor returns an object, this object will be
raised on abort.

Also add a convenience exception class named Fatal that can be
passed to Options() to exclusively catch situations in which
Options.parse() would have caused the program to exit.

Finally, set the default value to the onabort argument to call
sys.exit(97) as was previously the case.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
lib/bup/options.py