CommandObjectHelp.h revision 360784
1//===-- CommandObjectHelp.h -------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef liblldb_CommandObjectHelp_h_
10#define liblldb_CommandObjectHelp_h_
11
12#include "lldb/Host/OptionParser.h"
13#include "lldb/Interpreter/CommandObject.h"
14#include "lldb/Interpreter/Options.h"
15
16namespace lldb_private {
17
18// CommandObjectHelp
19
20class CommandObjectHelp : public CommandObjectParsed {
21public:
22  CommandObjectHelp(CommandInterpreter &interpreter);
23
24  ~CommandObjectHelp() override;
25
26  void HandleCompletion(CompletionRequest &request) override;
27
28  static void GenerateAdditionalHelpAvenuesMessage(
29      Stream *s, llvm::StringRef command, llvm::StringRef prefix,
30      llvm::StringRef subcommand, bool include_upropos = true,
31      bool include_type_lookup = true);
32
33  class CommandOptions : public Options {
34  public:
35    CommandOptions() : Options() {}
36
37    ~CommandOptions() override {}
38
39    Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
40                          ExecutionContext *execution_context) override {
41      Status error;
42      const int short_option = m_getopt_table[option_idx].val;
43
44      switch (short_option) {
45      case 'a':
46        m_show_aliases = false;
47        break;
48      case 'u':
49        m_show_user_defined = false;
50        break;
51      case 'h':
52        m_show_hidden = true;
53        break;
54      default:
55        llvm_unreachable("Unimplemented option");
56      }
57
58      return error;
59    }
60
61    void OptionParsingStarting(ExecutionContext *execution_context) override {
62      m_show_aliases = true;
63      m_show_user_defined = true;
64      m_show_hidden = false;
65    }
66
67    llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
68
69    // Instance variables to hold the values for command options.
70
71    bool m_show_aliases;
72    bool m_show_user_defined;
73    bool m_show_hidden;
74  };
75
76  Options *GetOptions() override { return &m_options; }
77
78protected:
79  bool DoExecute(Args &command, CommandReturnObject &result) override;
80
81private:
82  CommandOptions m_options;
83};
84
85} // namespace lldb_private
86
87#endif // liblldb_CommandObjectHelp_h_
88