11#include "llvm/ADT/STLExtras.h"
12#include "llvm/Support/ErrorHandling.h"
24 llvm::StringRef options_args,
29 if (options_args.size() < 1)
32 Args args(options_args);
33 std::string options_string(options_args);
38 Options *options = cmd_obj_sp->GetOptions();
43 cmd_obj_sp->GetCommandInterpreter().GetExecutionContext();
46 llvm::Expected<Args> args_or =
47 options->
ParseAlias(args, option_arg_vector, options_string);
50 result.
AppendError(
"Unable to create requested alias.\n");
53 args = std::move(*args_or);
57 result.
AppendError(
"Unable to create requested alias.\n");
62 if (!options_string.empty()) {
63 if (cmd_obj_sp->WantsRawCommandString())
67 for (
auto &entry : args.
entries()) {
68 if (!entry.ref().empty())
70 std::string(entry.ref()));
80 llvm::StringRef options_args, llvm::StringRef name,
81 llvm::StringRef help, llvm::StringRef syntax,
84 m_option_string(std::string(options_args)),
87 m_did_set_help_long(false) {
100 translation_and_help.
Printf(
140 llvm_unreachable(
"CommandAlias::Execute is not to be called");
145 help_string.
Printf(
"'%*s", (
int)command_name.size(), command_name.data());
156 for (
const auto &opt_entry : *options) {
157 std::tie(opt, std::ignore, value) = opt_entry;
159 help_string.
Printf(
" %s", value.c_str());
161 help_string.
Printf(
" %s", opt.c_str());
164 help_string.
Printf(
" %s", value.c_str());
183 std::tie(opt, std::ignore, value) = opt_entry;
185 llvm::StringRef(value).ends_with(
"--")) {
209 return {
nullptr,
nullptr};
211 if (underlying->IsAlias()) {
216 llvm::append_range(*options, *desugared.second);
218 return {desugared.first, options};
241 return llvm::StringRef();
249 return llvm::StringRef();
static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp, llvm::StringRef options_args, OptionArgVectorSP &option_arg_vector_sp)
A command line argument class.
llvm::ArrayRef< ArgEntry > entries() const
lldb::CommandObjectSP GetUnderlyingCommand()
llvm::StringRef GetHelpLong() override
void HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
LazyBool m_is_dashdash_alias
void Execute(const char *args_string, CommandReturnObject &result) override
OptionArgVectorSP GetOptionArguments() const
bool WantsCompletion() override
OptionArgVectorSP m_option_args_sp
Options * GetOptions() override
void SetHelp(llvm::StringRef str) override
bool WantsRawCommandString() override
void GetAliasExpansion(StreamString &help_string) const
void SetHelpLong(llvm::StringRef str) override
std::pair< lldb::CommandObjectSP, OptionArgVectorSP > Desugar()
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
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)
lldb::CommandObjectSP m_underlying_command_sp
llvm::StringRef GetHelp() override
bool IsDashDashCommand() override
static const char * g_no_argument
static const char * g_need_argument
static const char * g_argument
virtual void SetHelpLong(llvm::StringRef str)
std::vector< CommandArgumentEntry > m_arguments
std::string m_cmd_help_long
std::string m_cmd_help_short
virtual void SetHelp(llvm::StringRef str)
void void AppendError(llvm::StringRef in_string)
lldb::ReturnStatus GetStatus() const
"lldb/Utility/ArgCompletionRequest.h"
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A command line option parsing protocol class.
bool VerifyPartialOptions(CommandReturnObject &result)
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
llvm::Expected< Args > ParseAlias(const Args &args, OptionArgVector *option_arg_vector, std::string &input_line)
const char * GetData() const
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
std::shared_ptr< OptionArgVector > OptionArgVectorSP
const char * toString(AppleArm64ExceptionClass EC)
std::vector< std::tuple< std::string, int, std::string > > OptionArgVector
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP