16#include "llvm/Support/Regex.h"
25 interpreter,
"apropos",
26 "List debugger commands related to a word or subject.", nullptr) {
36 auto search_word = args[0].ref();
37 if (!search_word.empty()) {
40 std::string escaped_search_word;
41 std::optional<Stream::HighlightSettings> highlight;
44 escaped_search_word = llvm::Regex::escape(search_word);
53 search_word, commands_found, commands_help,
true,
true,
true,
true);
55 if (commands_found.
GetSize() == 0) {
57 "No commands found pertaining to '{0}'. "
58 "Try 'help' to see a complete list of "
63 "The following commands may relate to '{0}':", args[0].c_str());
65 for (
size_t i = 0; i < commands_found.
GetSize(); ++i)
74 size_t properties_max_len = 0;
75 std::vector<const Property *> properties;
76 const size_t num_properties =
78 for (
const Property *prop : properties) {
80 prop->DumpQualifiedName(qualified_name);
82 std::max(properties_max_len, qualified_name.
GetString().size());
85 if (num_properties == 0) {
87 "No settings found pertaining to '{0}'. "
88 "Try 'settings show' to see a complete list of "
94 "\nThe following settings variables may relate to '{0}': \n\n",
97 const bool dump_qualified_name =
true;
98 for (
size_t i = 0; i < num_properties; ++i)
99 properties[i]->DumpDescription(
101 dump_qualified_name, highlight);
107 result.
AppendError(
"'' is not a valid search word.\n");
110 result.
AppendError(
"'apropos' must be called with exactly one argument.\n");
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
~CommandObjectApropos() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectApropos(CommandInterpreter &interpreter)
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
CommandInterpreter & m_interpreter
void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void void AppendMessageWithFormatv(const char *format, Args &&...args)
Stream & GetOutputStream()
A class to manage flag bits.
llvm::StringRef GetRegexMatchAnsiSuffix() const
llvm::StringRef GetRegexMatchAnsiPrefix() const
size_t Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
llvm::StringRef GetString() const
size_t GetMaxStringLength() const
const char * GetStringAtIndex(size_t idx) const
A class that represents a running process on the host machine.
ReturnStatus
Command Return Status Types.
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult