blob: df1c0ab129292175e22897bda3c826354756e8c9 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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"
Enrico Granata08633ee2011-09-09 17:49:36 +000018#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019
20namespace lldb_private {
21
22//-------------------------------------------------------------------------
23// CommandObjectHelp
24//-------------------------------------------------------------------------
25
Kate Stoneb9c1b512016-09-06 20:57:50 +000026class CommandObjectHelp : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000028 CommandObjectHelp(CommandInterpreter &interpreter);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029
Kate Stoneb9c1b512016-09-06 20:57:50 +000030 ~CommandObjectHelp() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031
Kate Stoneb9c1b512016-09-06 20:57:50 +000032 int HandleCompletion(Args &input, int &cursor_index,
33 int &cursor_char_position, int match_start_point,
34 int max_return_elements, bool &word_complete,
35 StringList &matches) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000036
Kate Stoneb9c1b512016-09-06 20:57:50 +000037 static void GenerateAdditionalHelpAvenuesMessage(
38 Stream *s, const char *command, const char *prefix = nullptr,
39 const char *subcommand = nullptr, bool include_apropos = true,
40 bool include_type_lookup = true);
41
42 class CommandOptions : public Options {
43 public:
44 CommandOptions() : Options() {}
45
46 ~CommandOptions() override {}
47
48 Error SetOptionValue(uint32_t option_idx, const char *option_arg,
49 ExecutionContext *execution_context) override {
50 Error error;
51 const int short_option = m_getopt_table[option_idx].val;
52
53 switch (short_option) {
54 case 'a':
55 m_show_aliases = false;
56 break;
57 case 'u':
58 m_show_user_defined = false;
59 break;
60 case 'h':
61 m_show_hidden = true;
62 break;
63 default:
64 error.SetErrorStringWithFormat("unrecognized option '%c'",
65 short_option);
66 break;
67 }
68
69 return error;
Enrico Granata08633ee2011-09-09 17:49:36 +000070 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000071
72 void OptionParsingStarting(ExecutionContext *execution_context) override {
73 m_show_aliases = true;
74 m_show_user_defined = true;
75 m_show_hidden = false;
76 }
77
Zachary Turner1f0f5b52016-09-22 20:22:55 +000078 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
Kate Stoneb9c1b512016-09-06 20:57:50 +000079
80 // Instance variables to hold the values for command options.
81
82 bool m_show_aliases;
83 bool m_show_user_defined;
84 bool m_show_hidden;
85 };
86
87 Options *GetOptions() override { return &m_options; }
88
Jim Ingham5a988412012-06-08 21:56:10 +000089protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +000090 bool DoExecute(Args &command, CommandReturnObject &result) override;
91
Jim Ingham5a988412012-06-08 21:56:10 +000092private:
Kate Stoneb9c1b512016-09-06 20:57:50 +000093 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000094};
95
96} // namespace lldb_private
97
Pavel Labath1fb7e202015-09-02 09:33:09 +000098#endif // liblldb_CommandObjectHelp_h_