LLDB  mainline
CommandObjectHelp.h
Go to the documentation of this file.
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"
15 
16 namespace lldb_private {
17 
18 // CommandObjectHelp
19 
21 public:
23 
24  ~CommandObjectHelp() override;
25 
26  int HandleCompletion(CompletionRequest &request) override;
27 
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:
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  error.SetErrorStringWithFormat("unrecognized option '%c'",
56  short_option);
57  break;
58  }
59 
60  return error;
61  }
62 
63  void OptionParsingStarting(ExecutionContext *execution_context) override {
64  m_show_aliases = true;
65  m_show_user_defined = true;
66  m_show_hidden = false;
67  }
68 
69  llvm::ArrayRef<OptionDefinition> GetDefinitions() override;
70 
71  // Instance variables to hold the values for command options.
72 
76  };
77 
78  Options *GetOptions() override { return &m_options; }
79 
80 protected:
81  bool DoExecute(Args &command, CommandReturnObject &result) override;
82 
83 private:
84  CommandOptions m_options;
85 };
86 
87 } // namespace lldb_private
88 
89 #endif // liblldb_CommandObjectHelp_h_
A command line argument class.
Definition: Args.h:32
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
int HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
std::vector< Option > m_getopt_table
Definition: Options.h:209
bool DoExecute(Args &command, CommandReturnObject &result) override
"lldb/Utility/ArgCompletionRequest.h"
static void GenerateAdditionalHelpAvenuesMessage(Stream *s, llvm::StringRef command, llvm::StringRef prefix, llvm::StringRef subcommand, bool include_upropos=true, bool include_type_lookup=true)
A command line option parsing protocol class.
Definition: Options.h:62
CommandObjectHelp(CommandInterpreter &interpreter)
void OptionParsingStarting(ExecutionContext *execution_context) override
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
An error handling class.
Definition: Status.h:44