1""" Test command for checking the Python commands can run in a stop-hook """
2import lldb
3
4did_run = False
5
6class SomeCommand:
7    def __init__(self, debugger, unused):
8        self.dbg = debugger
9    def __call__(self, debugger, command, exe_ctx, result):
10        global did_run
11        did_run = True
12        result.PutCString("some output\n")
13
14    def get_short_help(self):
15        return "Test command - sets a variable."
16
17class OtherCommand:
18    def __init__(self, debugger, unused):
19        self.dbg = debugger
20    def __call__(self, debugger, command, exe_ctx, result):
21        global did_run
22        if did_run:
23            result.SetStatus(lldb.eReturnStatusSuccessFinishNoResult)
24        else:
25            result.SetStatus(lldb.eReturnStatusFailed)
26
27    def get_short_help(self):
28        return "Test command - sets a variable."
29
30def __lldb_init_module(debugger, unused):
31    print("Adding command some-cmd and report-cmd")
32    debugger.HandleCommand("command script add -c some_cmd.SomeCommand some-cmd")
33    debugger.HandleCommand("command script add -c some_cmd.OtherCommand report-cmd")
34