LLDB  mainline
CommandAlias.h
Go to the documentation of this file.
1 //===-- CommandAlias.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_CommandAlias_h_
10 #define liblldb_CommandAlias_h_
11 
12 #include <memory>
13 
15 #include "lldb/Utility/Args.h"
17 #include "lldb/lldb-forward.h"
18 
19 namespace lldb_private {
20 class CommandAlias : public CommandObject {
21 public:
22  typedef std::unique_ptr<CommandAlias> UniquePointer;
23 
24  CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp,
25  llvm::StringRef options_args, llvm::StringRef name,
26  llvm::StringRef help = llvm::StringRef(),
27  llvm::StringRef syntax = llvm::StringRef(), uint32_t flags = 0);
28 
29  void GetAliasExpansion(StreamString &help_string) const;
30 
31  bool IsValid() const { return m_underlying_command_sp && m_option_args_sp; }
32 
33  explicit operator bool() const { return IsValid(); }
34 
35  bool WantsRawCommandString() override;
36 
37  bool WantsCompletion() override;
38 
39  int HandleCompletion(CompletionRequest &request) override;
40 
42  CompletionRequest &request,
43  OptionElementVector &opt_element_vector) override;
44 
45  Options *GetOptions() override;
46 
47  bool IsAlias() override { return true; }
48 
49  bool IsDashDashCommand() override;
50 
51  llvm::StringRef GetHelp() override;
52 
53  llvm::StringRef GetHelpLong() override;
54 
55  void SetHelp(llvm::StringRef str) override;
56 
57  void SetHelpLong(llvm::StringRef str) override;
58 
59  bool Execute(const char *args_string, CommandReturnObject &result) override;
60 
61  lldb::CommandObjectSP GetUnderlyingCommand() {
62  return m_underlying_command_sp;
63  }
64  OptionArgVectorSP GetOptionArguments() const { return m_option_args_sp; }
65  const char *GetOptionString() { return m_option_string.c_str(); }
66 
67  // this takes an alias - potentially nested (i.e. an alias to an alias) and
68  // expands it all the way to a non-alias command
69  std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar();
70 
71 protected:
72  bool IsNestedAlias();
73 
74 private:
75  lldb::CommandObjectSP m_underlying_command_sp;
76  std::string m_option_string;
77  OptionArgVectorSP m_option_args_sp;
78  LazyBool m_is_dashdash_alias;
79  bool m_did_set_help : 1;
80  bool m_did_set_help_long : 1;
81 };
82 } // namespace lldb_private
83 
84 #endif // liblldb_CommandAlias_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
CommandAlias(CommandInterpreter &interpreter, lldb::CommandObjectSP cmd_sp, llvm::StringRef options_args, llvm::StringRef name, llvm::StringRef help=llvm::StringRef(), llvm::StringRef syntax=llvm::StringRef(), uint32_t flags=0)
llvm::StringRef GetHelpLong() override
std::pair< lldb::CommandObjectSP, OptionArgVectorSP > Desugar()
int HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
bool IsDashDashCommand() override
bool WantsRawCommandString() override
bool IsAlias() override
Definition: CommandAlias.h:47
"lldb/Utility/ArgCompletionRequest.h"
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:41
const char * GetOptionString()
Definition: CommandAlias.h:65
Options * GetOptions() override
std::unique_ptr< CommandAlias > UniquePointer
Definition: CommandAlias.h:22
OptionArgVectorSP GetOptionArguments() const
Definition: CommandAlias.h:64
int HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
A command line option parsing protocol class.
Definition: Options.h:62
lldb::CommandObjectSP GetUnderlyingCommand()
Definition: CommandAlias.h:61
void GetAliasExpansion(StreamString &help_string) const
std::shared_ptr< OptionArgVector > OptionArgVectorSP
Definition: Options.h:28
bool WantsCompletion() override
void SetHelp(llvm::StringRef str) override
llvm::StringRef GetHelp() override
void SetHelpLong(llvm::StringRef str) override
bool Execute(const char *args_string, CommandReturnObject &result) override