blob: a374a10e3e7d73cf2cee4915e36fd6581b4e1f88 [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
Jim Ingham5a988412012-06-08 21:56:10 +000026class CommandObjectHelp : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027{
28public:
29
Greg Claytona7015092010-09-18 01:14:36 +000030 CommandObjectHelp (CommandInterpreter &interpreter);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031
Pavel Labath1fb7e202015-09-02 09:33:09 +000032 ~CommandObjectHelp() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033
Pavel Labath1fb7e202015-09-02 09:33:09 +000034 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;
Enrico Granata08633ee2011-09-09 17:49:36 +000042
Enrico Granata46d4aa22016-02-29 23:22:53 +000043 static void
44 GenerateAdditionalHelpAvenuesMessage (Stream *s,
45 const char* command,
46 const char* prefix = nullptr,
47 const char* subcommand = nullptr,
48 bool include_apropos = true,
49 bool include_type_lookup = true);
50
Enrico Granata08633ee2011-09-09 17:49:36 +000051 class CommandOptions : public Options
52 {
53 public:
54
55 CommandOptions (CommandInterpreter &interpreter) :
56 Options (interpreter)
57 {
58 }
59
Pavel Labath1fb7e202015-09-02 09:33:09 +000060 ~CommandOptions() override {}
Enrico Granata08633ee2011-09-09 17:49:36 +000061
Pavel Labath1fb7e202015-09-02 09:33:09 +000062 Error
63 SetOptionValue(uint32_t option_idx, const char *option_arg) override
Enrico Granata08633ee2011-09-09 17:49:36 +000064 {
65 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +000066 const int short_option = m_getopt_table[option_idx].val;
Enrico Granata08633ee2011-09-09 17:49:36 +000067
68 switch (short_option)
69 {
70 case 'a':
Kate Stonea487aa42015-01-15 00:52:41 +000071 m_show_aliases = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000072 break;
73 case 'u':
74 m_show_user_defined = false;
75 break;
Kate Stonea487aa42015-01-15 00:52:41 +000076 case 'h':
77 m_show_hidden = true;
78 break;
Enrico Granata08633ee2011-09-09 17:49:36 +000079 default:
Greg Clayton86edbf42011-10-26 00:56:27 +000080 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Enrico Granata08633ee2011-09-09 17:49:36 +000081 break;
82 }
83
84 return error;
85 }
86
87 void
Pavel Labath1fb7e202015-09-02 09:33:09 +000088 OptionParsingStarting() override
Enrico Granata08633ee2011-09-09 17:49:36 +000089 {
Kate Stonea487aa42015-01-15 00:52:41 +000090 m_show_aliases = true;
Enrico Granata08633ee2011-09-09 17:49:36 +000091 m_show_user_defined = true;
Kate Stonea487aa42015-01-15 00:52:41 +000092 m_show_hidden = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000093 }
94
95 const OptionDefinition*
Pavel Labath1fb7e202015-09-02 09:33:09 +000096 GetDefinitions() override
Enrico Granata08633ee2011-09-09 17:49:36 +000097 {
98 return g_option_table;
99 }
100
101 // Options table: Required for subclasses of Options.
102
103 static OptionDefinition g_option_table[];
104
105 // Instance variables to hold the values for command options.
106
107 bool m_show_aliases;
Kate Stonea487aa42015-01-15 00:52:41 +0000108 bool m_show_user_defined;
109 bool m_show_hidden;
Enrico Granata08633ee2011-09-09 17:49:36 +0000110 };
111
Pavel Labath1fb7e202015-09-02 09:33:09 +0000112 Options *
113 GetOptions() override
Enrico Granata08633ee2011-09-09 17:49:36 +0000114 {
115 return &m_options;
116 }
Jim Ingham5a988412012-06-08 21:56:10 +0000117
118protected:
Pavel Labath1fb7e202015-09-02 09:33:09 +0000119 bool
120 DoExecute(Args& command,
121 CommandReturnObject &result) override;
Enrico Granata9b62d1d2013-06-12 01:50:57 +0000122
Jim Ingham5a988412012-06-08 21:56:10 +0000123private:
124 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000125};
126
127} // namespace lldb_private
128
Pavel Labath1fb7e202015-09-02 09:33:09 +0000129#endif // liblldb_CommandObjectHelp_h_