1# DExTer : Debugging Experience Tester 2# ~~~~~~ ~ ~~ ~ ~~ 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7"""This is a special subtool that is run when no subtool is specified. 8It just provides a welcome message and simple usage instructions. 9""" 10 11from dex.tools import ToolBase, get_tool_names 12from dex.utils.Exceptions import Error 13from dex.utils.ReturnCode import ReturnCode 14 15 16# This is a special "tool" that is run when no subtool has been specified on 17# the command line. Its only job is to provide useful usage info. 18class Tool(ToolBase): 19 """Welcome to DExTer (Debugging Experience Tester). 20 Please choose a subtool from the list below. Use 'dexter.py help' for more 21 information. 22 """ 23 24 @property 25 def name(self): 26 return 'DExTer' 27 28 def add_tool_arguments(self, parser, defaults): 29 parser.description = Tool.__doc__ 30 parser.add_argument( 31 'subtool', 32 choices=[t for t in get_tool_names() if not t.endswith('-')], 33 nargs='?', 34 help='name of subtool') 35 parser.add_argument( 36 'subtool_options', 37 metavar='subtool-options', 38 nargs='*', 39 help='subtool specific options') 40 41 def handle_options(self, defaults): 42 if not self.context.options.subtool: 43 raise Error('<d>no subtool specified</>\n\n{}\n'.format( 44 self.parser.format_help())) 45 46 def go(self) -> ReturnCode: 47 # This fn is never called because not specifying a subtool raises an 48 # exception. 49 return ReturnCode._ERROR 50