blob: 1dd7b9b8d6a8f66ed5dd367efa1e7cae8b559b7e [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
43 class CommandOptions : public Options
44 {
45 public:
46
47 CommandOptions (CommandInterpreter &interpreter) :
48 Options (interpreter)
49 {
50 }
51
Pavel Labath1fb7e202015-09-02 09:33:09 +000052 ~CommandOptions() override {}
Enrico Granata08633ee2011-09-09 17:49:36 +000053
Pavel Labath1fb7e202015-09-02 09:33:09 +000054 Error
55 SetOptionValue(uint32_t option_idx, const char *option_arg) override
Enrico Granata08633ee2011-09-09 17:49:36 +000056 {
57 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +000058 const int short_option = m_getopt_table[option_idx].val;
Enrico Granata08633ee2011-09-09 17:49:36 +000059
60 switch (short_option)
61 {
62 case 'a':
Kate Stonea487aa42015-01-15 00:52:41 +000063 m_show_aliases = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000064 break;
65 case 'u':
66 m_show_user_defined = false;
67 break;
Kate Stonea487aa42015-01-15 00:52:41 +000068 case 'h':
69 m_show_hidden = true;
70 break;
Enrico Granata08633ee2011-09-09 17:49:36 +000071 default:
Greg Clayton86edbf42011-10-26 00:56:27 +000072 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Enrico Granata08633ee2011-09-09 17:49:36 +000073 break;
74 }
75
76 return error;
77 }
78
79 void
Pavel Labath1fb7e202015-09-02 09:33:09 +000080 OptionParsingStarting() override
Enrico Granata08633ee2011-09-09 17:49:36 +000081 {
Kate Stonea487aa42015-01-15 00:52:41 +000082 m_show_aliases = true;
Enrico Granata08633ee2011-09-09 17:49:36 +000083 m_show_user_defined = true;
Kate Stonea487aa42015-01-15 00:52:41 +000084 m_show_hidden = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000085 }
86
87 const OptionDefinition*
Pavel Labath1fb7e202015-09-02 09:33:09 +000088 GetDefinitions() override
Enrico Granata08633ee2011-09-09 17:49:36 +000089 {
90 return g_option_table;
91 }
92
93 // Options table: Required for subclasses of Options.
94
95 static OptionDefinition g_option_table[];
96
97 // Instance variables to hold the values for command options.
98
99 bool m_show_aliases;
Kate Stonea487aa42015-01-15 00:52:41 +0000100 bool m_show_user_defined;
101 bool m_show_hidden;
Enrico Granata08633ee2011-09-09 17:49:36 +0000102 };
103
Pavel Labath1fb7e202015-09-02 09:33:09 +0000104 Options *
105 GetOptions() override
Enrico Granata08633ee2011-09-09 17:49:36 +0000106 {
107 return &m_options;
108 }
Jim Ingham5a988412012-06-08 21:56:10 +0000109
110protected:
Pavel Labath1fb7e202015-09-02 09:33:09 +0000111 bool
112 DoExecute(Args& command,
113 CommandReturnObject &result) override;
Enrico Granata9b62d1d2013-06-12 01:50:57 +0000114
Jim Ingham5a988412012-06-08 21:56:10 +0000115private:
116 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000117};
118
119} // namespace lldb_private
120
Pavel Labath1fb7e202015-09-02 09:33:09 +0000121#endif // liblldb_CommandObjectHelp_h_