blob: f1f87f8e63ccbb929deea0ec6f4119fa7debe280 [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
Zachary Turner3eb2b442017-03-22 23:33:16 +000017#include "lldb/Host/OptionParser.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000018#include "lldb/Interpreter/CommandObject.h"
Enrico Granata08633ee2011-09-09 17:49:36 +000019#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020
21namespace lldb_private {
22
23//-------------------------------------------------------------------------
24// CommandObjectHelp
25//-------------------------------------------------------------------------
26
Kate Stoneb9c1b512016-09-06 20:57:50 +000027class CommandObjectHelp : public CommandObjectParsed {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000028public:
Kate Stoneb9c1b512016-09-06 20:57:50 +000029 CommandObjectHelp(CommandInterpreter &interpreter);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000030
Kate Stoneb9c1b512016-09-06 20:57:50 +000031 ~CommandObjectHelp() override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000032
Kate Stoneb9c1b512016-09-06 20:57:50 +000033 int HandleCompletion(Args &input, int &cursor_index,
34 int &cursor_char_position, int match_start_point,
35 int max_return_elements, bool &word_complete,
36 StringList &matches) override;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000037
Kate Stoneb9c1b512016-09-06 20:57:50 +000038 static void GenerateAdditionalHelpAvenuesMessage(
Zachary Turnera49c2012016-11-16 21:34:22 +000039 Stream *s, llvm::StringRef command, llvm::StringRef prefix,
40 llvm::StringRef subcommand, bool include_apropos = true,
Kate Stoneb9c1b512016-09-06 20:57:50 +000041 bool include_type_lookup = true);
42
43 class CommandOptions : public Options {
44 public:
45 CommandOptions() : Options() {}
46
47 ~CommandOptions() override {}
48
Zachary Turner97206d52017-05-12 04:51:55 +000049 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
50 ExecutionContext *execution_context) override {
51 Status error;
Kate Stoneb9c1b512016-09-06 20:57:50 +000052 const int short_option = m_getopt_table[option_idx].val;
53
54 switch (short_option) {
55 case 'a':
56 m_show_aliases = false;
57 break;
58 case 'u':
59 m_show_user_defined = false;
60 break;
61 case 'h':
62 m_show_hidden = true;
63 break;
64 default:
65 error.SetErrorStringWithFormat("unrecognized option '%c'",
66 short_option);
67 break;
68 }
69
70 return error;
Enrico Granata08633ee2011-09-09 17:49:36 +000071 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000072
73 void OptionParsingStarting(ExecutionContext *execution_context) override {
74 m_show_aliases = true;
75 m_show_user_defined = true;
76 m_show_hidden = false;
77 }
78
Zachary Turner1f0f5b52016-09-22 20:22:55 +000079 llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
Kate Stoneb9c1b512016-09-06 20:57:50 +000080
81 // Instance variables to hold the values for command options.
82
83 bool m_show_aliases;
84 bool m_show_user_defined;
85 bool m_show_hidden;
86 };
87
88 Options *GetOptions() override { return &m_options; }
89
Jim Ingham5a988412012-06-08 21:56:10 +000090protected:
Kate Stoneb9c1b512016-09-06 20:57:50 +000091 bool DoExecute(Args &command, CommandReturnObject &result) override;
92
Jim Ingham5a988412012-06-08 21:56:10 +000093private:
Kate Stoneb9c1b512016-09-06 20:57:50 +000094 CommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095};
96
97} // namespace lldb_private
98
Pavel Labath1fb7e202015-09-02 09:33:09 +000099#endif // liblldb_CommandObjectHelp_h_