blob: 7db659c472c96ab7687145d25c41e1949aecdc08 [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
32 virtual
33 ~CommandObjectHelp ();
34
Chris Lattner30fdc8d2010-06-08 16:52:24 +000035 virtual int
Greg Claytona7015092010-09-18 01:14:36 +000036 HandleCompletion (Args &input,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000037 int &cursor_index,
38 int &cursor_char_position,
39 int match_start_point,
40 int max_return_elements,
Jim Ingham558ce122010-06-30 05:02:46 +000041 bool &word_complete,
Chris Lattner30fdc8d2010-06-08 16:52:24 +000042 StringList &matches);
Enrico Granata08633ee2011-09-09 17:49:36 +000043
44 class CommandOptions : public Options
45 {
46 public:
47
48 CommandOptions (CommandInterpreter &interpreter) :
49 Options (interpreter)
50 {
51 }
52
53 virtual
54 ~CommandOptions (){}
55
56 virtual Error
57 SetOptionValue (uint32_t option_idx, const char *option_arg)
58 {
59 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +000060 const int short_option = m_getopt_table[option_idx].val;
Enrico Granata08633ee2011-09-09 17:49:36 +000061
62 switch (short_option)
63 {
64 case 'a':
Kate Stonea487aa42015-01-15 00:52:41 +000065 m_show_aliases = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000066 break;
67 case 'u':
68 m_show_user_defined = false;
69 break;
Kate Stonea487aa42015-01-15 00:52:41 +000070 case 'h':
71 m_show_hidden = true;
72 break;
Enrico Granata08633ee2011-09-09 17:49:36 +000073 default:
Greg Clayton86edbf42011-10-26 00:56:27 +000074 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Enrico Granata08633ee2011-09-09 17:49:36 +000075 break;
76 }
77
78 return error;
79 }
80
81 void
82 OptionParsingStarting ()
83 {
Kate Stonea487aa42015-01-15 00:52:41 +000084 m_show_aliases = true;
Enrico Granata08633ee2011-09-09 17:49:36 +000085 m_show_user_defined = true;
Kate Stonea487aa42015-01-15 00:52:41 +000086 m_show_hidden = false;
Enrico Granata08633ee2011-09-09 17:49:36 +000087 }
88
89 const OptionDefinition*
90 GetDefinitions ()
91 {
92 return g_option_table;
93 }
94
95 // Options table: Required for subclasses of Options.
96
97 static OptionDefinition g_option_table[];
98
99 // Instance variables to hold the values for command options.
100
101 bool m_show_aliases;
Kate Stonea487aa42015-01-15 00:52:41 +0000102 bool m_show_user_defined;
103 bool m_show_hidden;
Enrico Granata08633ee2011-09-09 17:49:36 +0000104 };
105
Enrico Granata08633ee2011-09-09 17:49:36 +0000106 virtual Options *
107 GetOptions ()
108 {
109 return &m_options;
110 }
Jim Ingham5a988412012-06-08 21:56:10 +0000111
112protected:
113 virtual bool
114 DoExecute (Args& command,
115 CommandReturnObject &result);
Enrico Granata9b62d1d2013-06-12 01:50:57 +0000116
Jim Ingham5a988412012-06-08 21:56:10 +0000117private:
118 CommandOptions m_options;
119
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000120};
121
122} // namespace lldb_private
123
124#endif // liblldb_CommandObjectHelp_h_