api/cli: replace private variable access with method

This commit is contained in:
James R. Barlow
2022-06-11 15:29:59 -07:00
parent 0e550a1c6d
commit 31683530f8
2 changed files with 4 additions and 1 deletions

View File

@@ -193,7 +193,7 @@ def create_options(
else:
cmdline.append(os.fspath(output_file))
parser._api_mode = True
parser.enable_api_mode()
options = parser.parse_args(cmdline)
for keyword, val in deferred:
setattr(options, keyword, val)

View File

@@ -63,6 +63,9 @@ class ArgumentParser(argparse.ArgumentParser):
super().__init__(*args, **kwargs)
self._api_mode = False
def enable_api_mode(self):
self._api_mode = True
def error(self, message):
if not self._api_mode:
super().error(message)