[Lldb-commits] [lldb] Add the ability to define custom completers to the parsed_cmd template. (PR #109062)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 23 15:48:37 PDT 2024
================
@@ -43,7 +43,65 @@ def __call__(self, debugger, args_list, exe_ctx, result):
will return True if the user set this option, and False if it was left at its default
value.
-There are example commands in the lldb testsuite at:
+Custom Completions:
+
+You can also implement custom completers for your custom command, either for the
+arguments to your command or to the option values in your command. If you use enum
+values or if your option/argument uses is one of the types we have completers for,
+you should not need to do this. But if you have your own completeable types, or if
+you want completion of one option to be conditioned by other options on the command
+line, you can use this interface to take over the completion.
+
+You can choose to add a completion for the option values defined for your command,
+or for the arguments, separately. For the option values, define:
+
+def handle_option_argument_completion(self, long_option, cursor_pos):
+
+The line to be completed will be parsed up to the option containint the cursor position,
+and the values will be set in the OptionValue parser object. long_option will be
+the option name containing the cursor, and cursor_pos will be the position of the cursor
+in that option's value. You can call the OVParser.dest_for_option(long_option) to get the
+value for that option. The other options that came before the cursor in the command
+line will also be set in the OV Parser when the completion handler is called.
----------------
jimingham wrote:
I said I would call this `OVParser` for short at the beginning of the doc, then changed all the uses to `OVParser`...
https://github.com/llvm/llvm-project/pull/109062
More information about the lldb-commits
mailing list