1 //===-- CommandObjectHelp.h -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_CommandObjectHelp_h_ 11 #define liblldb_CommandObjectHelp_h_ 12 13 // C Includes 14 // C++ Includes 15 // Other libraries and framework includes 16 // Project includes 17 #include "lldb/Interpreter/CommandObject.h" 18 #include "lldb/Interpreter/Options.h" 19 20 namespace lldb_private { 21 22 //------------------------------------------------------------------------- 23 // CommandObjectHelp 24 //------------------------------------------------------------------------- 25 26 class CommandObjectHelp : public CommandObjectParsed 27 { 28 public: 29 30 CommandObjectHelp (CommandInterpreter &interpreter); 31 32 ~CommandObjectHelp() override; 33 34 int 35 HandleCompletion(Args &input, 36 int &cursor_index, 37 int &cursor_char_position, 38 int match_start_point, 39 int max_return_elements, 40 bool &word_complete, 41 StringList &matches) override; 42 43 class CommandOptions : public Options 44 { 45 public: 46 47 CommandOptions (CommandInterpreter &interpreter) : 48 Options (interpreter) 49 { 50 } 51 52 ~CommandOptions() override {} 53 54 Error 55 SetOptionValue(uint32_t option_idx, const char *option_arg) override 56 { 57 Error error; 58 const int short_option = m_getopt_table[option_idx].val; 59 60 switch (short_option) 61 { 62 case 'a': 63 m_show_aliases = false; 64 break; 65 case 'u': 66 m_show_user_defined = false; 67 break; 68 case 'h': 69 m_show_hidden = true; 70 break; 71 default: 72 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 73 break; 74 } 75 76 return error; 77 } 78 79 void 80 OptionParsingStarting() override 81 { 82 m_show_aliases = true; 83 m_show_user_defined = true; 84 m_show_hidden = false; 85 } 86 87 const OptionDefinition* 88 GetDefinitions() override 89 { 90 return g_option_table; 91 } 92 93 // Options table: Required for subclasses of Options. 94 95 static OptionDefinition g_option_table[]; 96 97 // Instance variables to hold the values for command options. 98 99 bool m_show_aliases; 100 bool m_show_user_defined; 101 bool m_show_hidden; 102 }; 103 104 Options * 105 GetOptions() override 106 { 107 return &m_options; 108 } 109 110 protected: 111 bool 112 DoExecute(Args& command, 113 CommandReturnObject &result) override; 114 115 private: 116 CommandOptions m_options; 117 }; 118 119 } // namespace lldb_private 120 121 #endif // liblldb_CommandObjectHelp_h_ 122