blob: 6e8f9d4cbc7b2715f2f464c85f8ee8e6f5c3d28d [file] [log] [blame]
Chris Lattner24943d22010-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 Granata1ac6d1f2011-09-09 17:49:36 +000018#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000019
20namespace lldb_private {
21
22//-------------------------------------------------------------------------
23// CommandObjectHelp
24//-------------------------------------------------------------------------
25
Jim Inghamda26bd22012-06-08 21:56:10 +000026class CommandObjectHelp : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +000027{
28public:
29
Greg Clayton238c0a12010-09-18 01:14:36 +000030 CommandObjectHelp (CommandInterpreter &interpreter);
Chris Lattner24943d22010-06-08 16:52:24 +000031
32 virtual
33 ~CommandObjectHelp ();
34
Chris Lattner24943d22010-06-08 16:52:24 +000035 virtual int
Greg Clayton238c0a12010-09-18 01:14:36 +000036 HandleCompletion (Args &input,
Chris Lattner24943d22010-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 Ingham802f8b02010-06-30 05:02:46 +000041 bool &word_complete,
Chris Lattner24943d22010-06-08 16:52:24 +000042 StringList &matches);
Enrico Granata1ac6d1f2011-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 Clayton6475c422012-12-04 00:32:51 +000060 const int short_option = m_getopt_table[option_idx].val;
Enrico Granata1ac6d1f2011-09-09 17:49:36 +000061
62 switch (short_option)
63 {
64 case 'a':
65 m_show_aliases = true;
66 break;
67 case 'u':
68 m_show_user_defined = false;
69 break;
70 default:
Greg Clayton9c236732011-10-26 00:56:27 +000071 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
Enrico Granata1ac6d1f2011-09-09 17:49:36 +000072 break;
73 }
74
75 return error;
76 }
77
78 void
79 OptionParsingStarting ()
80 {
81 m_show_aliases = false;
82 m_show_user_defined = true;
83 }
84
85 const OptionDefinition*
86 GetDefinitions ()
87 {
88 return g_option_table;
89 }
90
91 // Options table: Required for subclasses of Options.
92
93 static OptionDefinition g_option_table[];
94
95 // Instance variables to hold the values for command options.
96
97 bool m_show_aliases;
98 bool m_show_user_defined;
99 };
100
Enrico Granata1ac6d1f2011-09-09 17:49:36 +0000101 virtual Options *
102 GetOptions ()
103 {
104 return &m_options;
105 }
Jim Inghamda26bd22012-06-08 21:56:10 +0000106
107protected:
108 virtual bool
109 DoExecute (Args& command,
110 CommandReturnObject &result);
Enrico Granata035ef3d2013-06-12 01:50:57 +0000111
Jim Inghamda26bd22012-06-08 21:56:10 +0000112private:
113 CommandOptions m_options;
114
Chris Lattner24943d22010-06-08 16:52:24 +0000115};
116
117} // namespace lldb_private
118
119#endif // liblldb_CommandObjectHelp_h_