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