| 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. |
| 8 |
It just provides a welcome message and simple usage instructions. |
| 9 |
""" |
| 10 |
|
| 11 |
from dex.tools import ToolBase, get_tool_names |
| 12 |
from dex.utils.Exceptions import Error |
| 13 |
from 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. |
| 18 |
class 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 |
) |
| 36 |
parser.add_argument( |
| 37 |
"subtool_options", |
| 38 |
metavar="subtool-options", |
| 39 |
nargs="*", |
| 40 |
help="subtool specific options", |
| 41 |
) |
| 42 |
|
| 43 |
def handle_options(self, defaults): |
| 44 |
if not self.context.options.subtool: |
| 45 |
raise Error( |
| 46 |
"<d>no subtool specified</>\n\n{}\n".format(self.parser.format_help()) |
| 47 |
) |
| 48 |
|
| 49 |
def go(self) -> ReturnCode: |
| 50 |
# This fn is never called because not specifying a subtool raises an |
| 51 |
# exception. |
| 52 |
return ReturnCode._ERROR |