improved CSV output and error handling

This commit is contained in:
Tobias Diekershoff 2023-01-14 12:36:24 +01:00
parent 1fe4f2df10
commit db7565dcd0

View file

@ -1,27 +0,0 @@
#!/usr/bin/env python
# SPDX-FileCopyrightText: 2023 Tobias Diekershoff
#
# SPDX-License-Identifier: CC-BY-SA-2.5
"""
This expansion of the ArgParser class will display the --help results by
default if an error occurs (e.g. no arguments are passed to the script).
It is based on an StackOverflow answer from 2010 by unutbu who refered to
a reply from Steven Bethard as source of the code. Postings of that time
on StackOverflow are published under the terms of a CreativeCommons license
specifically under the CC-BY-SA-2.5 so this module is put under the same
license.
https://stackoverflow.com/questions/4042452/display-help-message-with-python-argparse-when-script-is-called-without-any-argu/4042861#4042861
"""
import argparse
import sys
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(2)