16#include "llvm/Support/Regex.h"
25 interpreter,
"apropos",
26 "List debugger commands and settings related to a word or subject.",
37 auto search_word = args[0].ref();
38 if (!search_word.empty()) {
41 std::string escaped_search_word;
42 std::optional<Stream::HighlightSettings> highlight;
45 escaped_search_word = llvm::Regex::escape(search_word);
54 search_word, commands_found, commands_help,
true,
true,
true,
true);
56 if (commands_found.
GetSize() == 0) {
58 "No commands found pertaining to '{0}'. "
59 "Try 'help' to see a complete list of "
64 "The following commands may relate to '{0}':", args[0].c_str());
66 for (
size_t i = 0; i < commands_found.
GetSize(); ++i)
75 size_t properties_max_len = 0;
76 std::vector<const Property *> properties;
77 std::vector<const Property *> property_paths;
79 for (
const Property *prop : properties) {
81 prop->DumpQualifiedName(qualified_name);
83 std::max(properties_max_len, qualified_name.
GetString().size());
86 if (properties.empty() && property_paths.empty()) {
88 "No settings found pertaining to '{0}'. "
89 "Try 'settings show' to see a complete list of "
96 if (!property_paths.empty()) {
98 "\nThe following settings paths may relate to '{0}': \n\n",
103 for (
auto path : property_paths) {
105 if (path->DumpQualifiedName(qual_name_strm, highlight)) {
110 out_strm.IndentLess();
113 "show settings with a given path)");
116 if (!properties.empty()) {
118 "\nThe following settings variables may relate to '{0}': \n\n",
121 const bool dump_qualified_name =
true;
122 for (
auto property : properties)
124 properties_max_len, dump_qualified_name,
130 result.
AppendError(
"'' is not a valid search word.\n");
133 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
void Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties, std::vector< const Property * > &matching_property_paths) const
llvm::StringRef GetString() const
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
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