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 virtual 33 ~CommandObjectHelp (); 34 35 virtual int 36 HandleCompletion (Args &input, 37 int &cursor_index, 38 int &cursor_char_position, 39 int match_start_point, 40 int max_return_elements, 41 bool &word_complete, 42 StringList &matches); 43 44 class CommandOptions : public Options 45 { 46 public: 47 48 CommandOptions (CommandInterpreter &interpreter) : 49 Options (interpreter) 50 { 51 } 52 53 virtual 54 ~CommandOptions (){} 55 56 virtual Error 57 SetOptionValue (uint32_t option_idx, const char *option_arg) 58 { 59 Error error; 60 const int short_option = m_getopt_table[option_idx].val; 61 62 switch (short_option) 63 { 64 case 'a': 65 m_show_aliases = false; 66 break; 67 case 'u': 68 m_show_user_defined = false; 69 break; 70 case 'h': 71 m_show_hidden = true; 72 break; 73 default: 74 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 75 break; 76 } 77 78 return error; 79 } 80 81 void 82 OptionParsingStarting () 83 { 84 m_show_aliases = true; 85 m_show_user_defined = true; 86 m_show_hidden = false; 87 } 88 89 const OptionDefinition* 90 GetDefinitions () 91 { 92 return g_option_table; 93 } 94 95 // Options table: Required for subclasses of Options. 96 97 static OptionDefinition g_option_table[]; 98 99 // Instance variables to hold the values for command options. 100 101 bool m_show_aliases; 102 bool m_show_user_defined; 103 bool m_show_hidden; 104 }; 105 106 virtual Options * 107 GetOptions () 108 { 109 return &m_options; 110 } 111 112 protected: 113 virtual bool 114 DoExecute (Args& command, 115 CommandReturnObject &result); 116 117 private: 118 CommandOptions m_options; 119 120 }; 121 122 } // namespace lldb_private 123 124 #endif // liblldb_CommandObjectHelp_h_ 125