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/Host/OptionParser.h" 18 #include "lldb/Interpreter/CommandObject.h" 19 #include "lldb/Interpreter/Options.h" 20 21 namespace lldb_private { 22 23 //------------------------------------------------------------------------- 24 // CommandObjectHelp 25 //------------------------------------------------------------------------- 26 27 class CommandObjectHelp : public CommandObjectParsed { 28 public: 29 CommandObjectHelp(CommandInterpreter &interpreter); 30 31 ~CommandObjectHelp() override; 32 33 int HandleCompletion(Args &input, int &cursor_index, 34 int &cursor_char_position, int match_start_point, 35 int max_return_elements, bool &word_complete, 36 StringList &matches) override; 37 38 static void GenerateAdditionalHelpAvenuesMessage( 39 Stream *s, llvm::StringRef command, llvm::StringRef prefix, 40 llvm::StringRef subcommand, bool include_apropos = true, 41 bool include_type_lookup = true); 42 43 class CommandOptions : public Options { 44 public: 45 CommandOptions() : Options() {} 46 47 ~CommandOptions() override {} 48 49 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, 50 ExecutionContext *execution_context) override { 51 Status error; 52 const int short_option = m_getopt_table[option_idx].val; 53 54 switch (short_option) { 55 case 'a': 56 m_show_aliases = false; 57 break; 58 case 'u': 59 m_show_user_defined = false; 60 break; 61 case 'h': 62 m_show_hidden = true; 63 break; 64 default: 65 error.SetErrorStringWithFormat("unrecognized option '%c'", 66 short_option); 67 break; 68 } 69 70 return error; 71 } 72 73 void OptionParsingStarting(ExecutionContext *execution_context) override { 74 m_show_aliases = true; 75 m_show_user_defined = true; 76 m_show_hidden = false; 77 } 78 79 llvm::ArrayRef<OptionDefinition> GetDefinitions() override; 80 81 // Instance variables to hold the values for command options. 82 83 bool m_show_aliases; 84 bool m_show_user_defined; 85 bool m_show_hidden; 86 }; 87 88 Options *GetOptions() override { return &m_options; } 89 90 protected: 91 bool DoExecute(Args &command, CommandReturnObject &result) override; 92 93 private: 94 CommandOptions m_options; 95 }; 96 97 } // namespace lldb_private 98 99 #endif // liblldb_CommandObjectHelp_h_ 100