1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 5# 6# HDF is dual licensed: you can use it either under the terms of 7# the GPL, or the BSD license, at your option. 8# See the LICENSE file in the root of this repository for complete details. 9 10 11import argparse 12 13from command_line.hdf_command_error_code import CommandErrorCode 14from hdf_tool_exception import HdfToolException 15 16 17class HdfToolArgumentParser(argparse.ArgumentParser): 18 def exit(self, status=0, message=None): 19 if status: 20 raise HdfToolException(message, CommandErrorCode.INTERFACE_ERROR) 21 exit(status) 22 23 def error(self, message): 24 self.exit(2, 'error: %s\n' % message) 25