1ac7ddfbfSEd Maste //===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste
104bb0738eSEd Maste #include "lldb/Interpreter/CommandObjectMultiword.h"
11ac7ddfbfSEd Maste #include "lldb/Core/Debugger.h"
12ac7ddfbfSEd Maste #include "lldb/Interpreter/CommandInterpreter.h"
13ac7ddfbfSEd Maste #include "lldb/Interpreter/CommandReturnObject.h"
14435933ddSDimitry Andric #include "lldb/Interpreter/Options.h"
15ac7ddfbfSEd Maste
16ac7ddfbfSEd Maste using namespace lldb;
17ac7ddfbfSEd Maste using namespace lldb_private;
18ac7ddfbfSEd Maste
19ac7ddfbfSEd Maste //-------------------------------------------------------------------------
20ac7ddfbfSEd Maste // CommandObjectMultiword
21ac7ddfbfSEd Maste //-------------------------------------------------------------------------
22ac7ddfbfSEd Maste
CommandObjectMultiword(CommandInterpreter & interpreter,const char * name,const char * help,const char * syntax,uint32_t flags)234bb0738eSEd Maste CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter,
24ac7ddfbfSEd Maste const char *name,
25ac7ddfbfSEd Maste const char *help,
26ac7ddfbfSEd Maste const char *syntax,
27435933ddSDimitry Andric uint32_t flags)
28435933ddSDimitry Andric : CommandObject(interpreter, name, help, syntax, flags),
29435933ddSDimitry Andric m_can_be_removed(false) {}
30ac7ddfbfSEd Maste
314bb0738eSEd Maste CommandObjectMultiword::~CommandObjectMultiword() = default;
32ac7ddfbfSEd Maste
GetSubcommandSP(llvm::StringRef sub_cmd,StringList * matches)33435933ddSDimitry Andric CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
34435933ddSDimitry Andric StringList *matches) {
35ac7ddfbfSEd Maste CommandObjectSP return_cmd_sp;
36ac7ddfbfSEd Maste CommandObject::CommandMap::iterator pos;
37ac7ddfbfSEd Maste
38435933ddSDimitry Andric if (!m_subcommand_dict.empty()) {
39ac7ddfbfSEd Maste pos = m_subcommand_dict.find(sub_cmd);
40ac7ddfbfSEd Maste if (pos != m_subcommand_dict.end()) {
41ac7ddfbfSEd Maste // An exact match; append the sub_cmd to the 'matches' string list.
42ac7ddfbfSEd Maste if (matches)
43ac7ddfbfSEd Maste matches->AppendString(sub_cmd);
44ac7ddfbfSEd Maste return_cmd_sp = pos->second;
45435933ddSDimitry Andric } else {
46ac7ddfbfSEd Maste StringList local_matches;
474bb0738eSEd Maste if (matches == nullptr)
48ac7ddfbfSEd Maste matches = &local_matches;
49435933ddSDimitry Andric int num_matches =
50435933ddSDimitry Andric AddNamesMatchingPartialString(m_subcommand_dict, sub_cmd, *matches);
51ac7ddfbfSEd Maste
52435933ddSDimitry Andric if (num_matches == 1) {
53435933ddSDimitry Andric // Cleaner, but slightly less efficient would be to call back into this
544ba319b5SDimitry Andric // function, since I now know I have an exact match...
55ac7ddfbfSEd Maste
56ac7ddfbfSEd Maste sub_cmd = matches->GetStringAtIndex(0);
57ac7ddfbfSEd Maste pos = m_subcommand_dict.find(sub_cmd);
58ac7ddfbfSEd Maste if (pos != m_subcommand_dict.end())
59ac7ddfbfSEd Maste return_cmd_sp = pos->second;
60ac7ddfbfSEd Maste }
61ac7ddfbfSEd Maste }
62ac7ddfbfSEd Maste }
63ac7ddfbfSEd Maste return return_cmd_sp;
64ac7ddfbfSEd Maste }
65ac7ddfbfSEd Maste
66ac7ddfbfSEd Maste CommandObject *
GetSubcommandObject(llvm::StringRef sub_cmd,StringList * matches)67435933ddSDimitry Andric CommandObjectMultiword::GetSubcommandObject(llvm::StringRef sub_cmd,
68435933ddSDimitry Andric StringList *matches) {
69ac7ddfbfSEd Maste return GetSubcommandSP(sub_cmd, matches).get();
70ac7ddfbfSEd Maste }
71ac7ddfbfSEd Maste
LoadSubCommand(llvm::StringRef name,const CommandObjectSP & cmd_obj)72435933ddSDimitry Andric bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
73435933ddSDimitry Andric const CommandObjectSP &cmd_obj) {
744bb0738eSEd Maste if (cmd_obj)
75435933ddSDimitry Andric assert((&GetCommandInterpreter() == &cmd_obj->GetCommandInterpreter()) &&
76435933ddSDimitry Andric "tried to add a CommandObject from a different interpreter");
774bb0738eSEd Maste
78ac7ddfbfSEd Maste CommandMap::iterator pos;
79ac7ddfbfSEd Maste bool success = true;
80ac7ddfbfSEd Maste
81ac7ddfbfSEd Maste pos = m_subcommand_dict.find(name);
82435933ddSDimitry Andric if (pos == m_subcommand_dict.end()) {
83ac7ddfbfSEd Maste m_subcommand_dict[name] = cmd_obj;
84435933ddSDimitry Andric } else
85ac7ddfbfSEd Maste success = false;
86ac7ddfbfSEd Maste
87ac7ddfbfSEd Maste return success;
88ac7ddfbfSEd Maste }
89ac7ddfbfSEd Maste
Execute(const char * args_string,CommandReturnObject & result)90435933ddSDimitry Andric bool CommandObjectMultiword::Execute(const char *args_string,
91435933ddSDimitry Andric CommandReturnObject &result) {
92ac7ddfbfSEd Maste Args args(args_string);
93ac7ddfbfSEd Maste const size_t argc = args.GetArgumentCount();
94435933ddSDimitry Andric if (argc == 0) {
95ac7ddfbfSEd Maste this->CommandObject::GenerateHelpText(result);
96435933ddSDimitry Andric return result.Succeeded();
97ac7ddfbfSEd Maste }
98ac7ddfbfSEd Maste
99435933ddSDimitry Andric auto sub_command = args[0].ref;
100435933ddSDimitry Andric if (sub_command.empty())
101435933ddSDimitry Andric return result.Succeeded();
102435933ddSDimitry Andric
103435933ddSDimitry Andric if (sub_command.equals_lower("help")) {
104ac7ddfbfSEd Maste this->CommandObject::GenerateHelpText(result);
105435933ddSDimitry Andric return result.Succeeded();
106ac7ddfbfSEd Maste }
107435933ddSDimitry Andric
108435933ddSDimitry Andric if (m_subcommand_dict.empty()) {
109435933ddSDimitry Andric result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
110435933ddSDimitry Andric GetCommandName().str().c_str());
111435933ddSDimitry Andric result.SetStatus(eReturnStatusFailed);
112435933ddSDimitry Andric return false;
113435933ddSDimitry Andric }
114435933ddSDimitry Andric
115ac7ddfbfSEd Maste StringList matches;
116ac7ddfbfSEd Maste CommandObject *sub_cmd_obj = GetSubcommandObject(sub_command, &matches);
117435933ddSDimitry Andric if (sub_cmd_obj != nullptr) {
118435933ddSDimitry Andric // Now call CommandObject::Execute to process options in `rest_of_line`.
1194ba319b5SDimitry Andric // From there the command-specific version of Execute will be called, with
1204ba319b5SDimitry Andric // the processed arguments.
121ac7ddfbfSEd Maste
122ac7ddfbfSEd Maste args.Shift();
123ac7ddfbfSEd Maste sub_cmd_obj->Execute(args_string, result);
124435933ddSDimitry Andric return result.Succeeded();
125ac7ddfbfSEd Maste }
126435933ddSDimitry Andric
127ac7ddfbfSEd Maste std::string error_msg;
128ac7ddfbfSEd Maste const size_t num_subcmd_matches = matches.GetSize();
129ac7ddfbfSEd Maste if (num_subcmd_matches > 0)
130ac7ddfbfSEd Maste error_msg.assign("ambiguous command ");
131ac7ddfbfSEd Maste else
132ac7ddfbfSEd Maste error_msg.assign("invalid command ");
133ac7ddfbfSEd Maste
134ac7ddfbfSEd Maste error_msg.append("'");
135ac7ddfbfSEd Maste error_msg.append(GetCommandName());
136ac7ddfbfSEd Maste error_msg.append(" ");
137ac7ddfbfSEd Maste error_msg.append(sub_command);
1381c3bbb01SEd Maste error_msg.append("'.");
139ac7ddfbfSEd Maste
140435933ddSDimitry Andric if (num_subcmd_matches > 0) {
141ac7ddfbfSEd Maste error_msg.append(" Possible completions:");
1424ba319b5SDimitry Andric for (size_t i = 0; i < matches.GetSize(); i++) {
143ac7ddfbfSEd Maste error_msg.append("\n\t");
144ac7ddfbfSEd Maste error_msg.append(matches.GetStringAtIndex(i));
145ac7ddfbfSEd Maste }
146ac7ddfbfSEd Maste }
147ac7ddfbfSEd Maste error_msg.append("\n");
148ac7ddfbfSEd Maste result.AppendRawError(error_msg.c_str());
149ac7ddfbfSEd Maste result.SetStatus(eReturnStatusFailed);
150435933ddSDimitry Andric return false;
151ac7ddfbfSEd Maste }
152ac7ddfbfSEd Maste
GenerateHelpText(Stream & output_stream)153435933ddSDimitry Andric void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
1544ba319b5SDimitry Andric // First time through here, generate the help text for the object and push it
1554ba319b5SDimitry Andric // to the return result object as well
156ac7ddfbfSEd Maste
1574bb0738eSEd Maste CommandObject::GenerateHelpText(output_stream);
1584bb0738eSEd Maste output_stream.PutCString("\nThe following subcommands are supported:\n\n");
159ac7ddfbfSEd Maste
160ac7ddfbfSEd Maste CommandMap::iterator pos;
1614bb0738eSEd Maste uint32_t max_len = FindLongestCommandWord(m_subcommand_dict);
162ac7ddfbfSEd Maste
163ac7ddfbfSEd Maste if (max_len)
164ac7ddfbfSEd Maste max_len += 4; // Indent the output by 4 spaces.
165ac7ddfbfSEd Maste
166435933ddSDimitry Andric for (pos = m_subcommand_dict.begin(); pos != m_subcommand_dict.end(); ++pos) {
167ac7ddfbfSEd Maste std::string indented_command(" ");
168ac7ddfbfSEd Maste indented_command.append(pos->first);
169435933ddSDimitry Andric if (pos->second->WantsRawCommandString()) {
170ac7ddfbfSEd Maste std::string help_text(pos->second->GetHelp());
1714bb0738eSEd Maste help_text.append(" Expects 'raw' input (see 'help raw-input'.)");
172ac7ddfbfSEd Maste m_interpreter.OutputFormattedHelpText(output_stream,
173435933ddSDimitry Andric indented_command.c_str(), "--",
174435933ddSDimitry Andric help_text.c_str(), max_len);
175435933ddSDimitry Andric } else
176ac7ddfbfSEd Maste m_interpreter.OutputFormattedHelpText(output_stream,
177435933ddSDimitry Andric indented_command.c_str(), "--",
178435933ddSDimitry Andric pos->second->GetHelp(), max_len);
179ac7ddfbfSEd Maste }
180ac7ddfbfSEd Maste
181435933ddSDimitry Andric output_stream.PutCString("\nFor more help on any particular subcommand, type "
182435933ddSDimitry Andric "'help <command> <subcommand>'.\n");
183ac7ddfbfSEd Maste }
184ac7ddfbfSEd Maste
HandleCompletion(CompletionRequest & request)1854ba319b5SDimitry Andric int CommandObjectMultiword::HandleCompletion(CompletionRequest &request) {
186435933ddSDimitry Andric // Any of the command matches will provide a complete word, otherwise the
187435933ddSDimitry Andric // individual completers will override this.
1884ba319b5SDimitry Andric request.SetWordComplete(true);
189ac7ddfbfSEd Maste
1904ba319b5SDimitry Andric auto arg0 = request.GetParsedLine()[0].ref;
1914ba319b5SDimitry Andric if (request.GetCursorIndex() == 0) {
192*b5893f02SDimitry Andric StringList new_matches, descriptions;
193*b5893f02SDimitry Andric AddNamesMatchingPartialString(m_subcommand_dict, arg0, new_matches,
194*b5893f02SDimitry Andric &descriptions);
195*b5893f02SDimitry Andric request.AddCompletions(new_matches, descriptions);
196ac7ddfbfSEd Maste
1974ba319b5SDimitry Andric if (new_matches.GetSize() == 1 &&
1984ba319b5SDimitry Andric new_matches.GetStringAtIndex(0) != nullptr &&
1994ba319b5SDimitry Andric (arg0 == new_matches.GetStringAtIndex(0))) {
200ac7ddfbfSEd Maste StringList temp_matches;
201435933ddSDimitry Andric CommandObject *cmd_obj = GetSubcommandObject(arg0, &temp_matches);
202435933ddSDimitry Andric if (cmd_obj != nullptr) {
2034ba319b5SDimitry Andric if (request.GetParsedLine().GetArgumentCount() == 1) {
2044ba319b5SDimitry Andric request.SetWordComplete(true);
205435933ddSDimitry Andric } else {
2064ba319b5SDimitry Andric request.GetParsedLine().Shift();
2074ba319b5SDimitry Andric request.SetCursorCharPosition(0);
2084ba319b5SDimitry Andric request.GetParsedLine().AppendArgument(llvm::StringRef());
2094ba319b5SDimitry Andric return cmd_obj->HandleCompletion(request);
210ac7ddfbfSEd Maste }
211ac7ddfbfSEd Maste }
2121c3bbb01SEd Maste }
2134ba319b5SDimitry Andric return new_matches.GetSize();
214435933ddSDimitry Andric } else {
2154ba319b5SDimitry Andric StringList new_matches;
2164ba319b5SDimitry Andric CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches);
217435933ddSDimitry Andric if (sub_command_object == nullptr) {
2184ba319b5SDimitry Andric request.AddCompletions(new_matches);
2194ba319b5SDimitry Andric return request.GetNumberOfMatches();
220435933ddSDimitry Andric } else {
221ac7ddfbfSEd Maste // Remove the one match that we got from calling GetSubcommandObject.
2224ba319b5SDimitry Andric new_matches.DeleteStringAtIndex(0);
2234ba319b5SDimitry Andric request.AddCompletions(new_matches);
2244ba319b5SDimitry Andric request.GetParsedLine().Shift();
2254ba319b5SDimitry Andric request.SetCursorIndex(request.GetCursorIndex() - 1);
2264ba319b5SDimitry Andric return sub_command_object->HandleCompletion(request);
227ac7ddfbfSEd Maste }
228ac7ddfbfSEd Maste }
229ac7ddfbfSEd Maste }
230ac7ddfbfSEd Maste
GetRepeatCommand(Args & current_command_args,uint32_t index)231435933ddSDimitry Andric const char *CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args,
232435933ddSDimitry Andric uint32_t index) {
233ac7ddfbfSEd Maste index++;
234ac7ddfbfSEd Maste if (current_command_args.GetArgumentCount() <= index)
2354bb0738eSEd Maste return nullptr;
236435933ddSDimitry Andric CommandObject *sub_command_object =
237435933ddSDimitry Andric GetSubcommandObject(current_command_args[index].ref);
2384bb0738eSEd Maste if (sub_command_object == nullptr)
2394bb0738eSEd Maste return nullptr;
240ac7ddfbfSEd Maste return sub_command_object->GetRepeatCommand(current_command_args, index);
241ac7ddfbfSEd Maste }
242ac7ddfbfSEd Maste
AproposAllSubCommands(llvm::StringRef prefix,llvm::StringRef search_word,StringList & commands_found,StringList & commands_help)243435933ddSDimitry Andric void CommandObjectMultiword::AproposAllSubCommands(llvm::StringRef prefix,
244435933ddSDimitry Andric llvm::StringRef search_word,
245ac7ddfbfSEd Maste StringList &commands_found,
246435933ddSDimitry Andric StringList &commands_help) {
247ac7ddfbfSEd Maste CommandObject::CommandMap::const_iterator pos;
248ac7ddfbfSEd Maste
249435933ddSDimitry Andric for (pos = m_subcommand_dict.begin(); pos != m_subcommand_dict.end(); ++pos) {
250ac7ddfbfSEd Maste const char *command_name = pos->first.c_str();
251ac7ddfbfSEd Maste CommandObject *sub_cmd_obj = pos->second.get();
252ac7ddfbfSEd Maste StreamString complete_command_name;
253ac7ddfbfSEd Maste
254435933ddSDimitry Andric complete_command_name << prefix << " " << command_name;
255ac7ddfbfSEd Maste
256435933ddSDimitry Andric if (sub_cmd_obj->HelpTextContainsWord(search_word)) {
257435933ddSDimitry Andric commands_found.AppendString(complete_command_name.GetString());
258ac7ddfbfSEd Maste commands_help.AppendString(sub_cmd_obj->GetHelp());
259ac7ddfbfSEd Maste }
260ac7ddfbfSEd Maste
261ac7ddfbfSEd Maste if (sub_cmd_obj->IsMultiwordObject())
262435933ddSDimitry Andric sub_cmd_obj->AproposAllSubCommands(complete_command_name.GetString(),
263435933ddSDimitry Andric search_word, commands_found,
264ac7ddfbfSEd Maste commands_help);
265ac7ddfbfSEd Maste }
266ac7ddfbfSEd Maste }
267ac7ddfbfSEd Maste
CommandObjectProxy(CommandInterpreter & interpreter,const char * name,const char * help,const char * syntax,uint32_t flags)268ac7ddfbfSEd Maste CommandObjectProxy::CommandObjectProxy(CommandInterpreter &interpreter,
269435933ddSDimitry Andric const char *name, const char *help,
270435933ddSDimitry Andric const char *syntax, uint32_t flags)
271435933ddSDimitry Andric : CommandObject(interpreter, name, help, syntax, flags) {}
272ac7ddfbfSEd Maste
2734bb0738eSEd Maste CommandObjectProxy::~CommandObjectProxy() = default;
274ac7ddfbfSEd Maste
GetHelpLong()275435933ddSDimitry Andric llvm::StringRef CommandObjectProxy::GetHelpLong() {
276ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
277ac7ddfbfSEd Maste if (proxy_command)
278ac7ddfbfSEd Maste return proxy_command->GetHelpLong();
279435933ddSDimitry Andric return llvm::StringRef();
280ac7ddfbfSEd Maste }
281ac7ddfbfSEd Maste
IsRemovable() const282435933ddSDimitry Andric bool CommandObjectProxy::IsRemovable() const {
283435933ddSDimitry Andric const CommandObject *proxy_command =
284435933ddSDimitry Andric const_cast<CommandObjectProxy *>(this)->GetProxyCommandObject();
285ac7ddfbfSEd Maste if (proxy_command)
286ac7ddfbfSEd Maste return proxy_command->IsRemovable();
287ac7ddfbfSEd Maste return false;
288ac7ddfbfSEd Maste }
289ac7ddfbfSEd Maste
IsMultiwordObject()290435933ddSDimitry Andric bool CommandObjectProxy::IsMultiwordObject() {
291ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
292ac7ddfbfSEd Maste if (proxy_command)
293ac7ddfbfSEd Maste return proxy_command->IsMultiwordObject();
294ac7ddfbfSEd Maste return false;
295ac7ddfbfSEd Maste }
296ac7ddfbfSEd Maste
GetAsMultiwordCommand()297435933ddSDimitry Andric CommandObjectMultiword *CommandObjectProxy::GetAsMultiwordCommand() {
2984bb0738eSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
2994bb0738eSEd Maste if (proxy_command)
3004bb0738eSEd Maste return proxy_command->GetAsMultiwordCommand();
3014bb0738eSEd Maste return nullptr;
3024bb0738eSEd Maste }
3034bb0738eSEd Maste
GenerateHelpText(Stream & result)304435933ddSDimitry Andric void CommandObjectProxy::GenerateHelpText(Stream &result) {
3059f2f44ceSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
3069f2f44ceSEd Maste if (proxy_command)
3079f2f44ceSEd Maste return proxy_command->GenerateHelpText(result);
3089f2f44ceSEd Maste }
3099f2f44ceSEd Maste
310ac7ddfbfSEd Maste lldb::CommandObjectSP
GetSubcommandSP(llvm::StringRef sub_cmd,StringList * matches)311435933ddSDimitry Andric CommandObjectProxy::GetSubcommandSP(llvm::StringRef sub_cmd,
312435933ddSDimitry Andric StringList *matches) {
313ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
314ac7ddfbfSEd Maste if (proxy_command)
315ac7ddfbfSEd Maste return proxy_command->GetSubcommandSP(sub_cmd, matches);
316ac7ddfbfSEd Maste return lldb::CommandObjectSP();
317ac7ddfbfSEd Maste }
318ac7ddfbfSEd Maste
GetSubcommandObject(llvm::StringRef sub_cmd,StringList * matches)319435933ddSDimitry Andric CommandObject *CommandObjectProxy::GetSubcommandObject(llvm::StringRef sub_cmd,
320435933ddSDimitry Andric StringList *matches) {
321ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
322ac7ddfbfSEd Maste if (proxy_command)
323ac7ddfbfSEd Maste return proxy_command->GetSubcommandObject(sub_cmd, matches);
3244bb0738eSEd Maste return nullptr;
325ac7ddfbfSEd Maste }
326ac7ddfbfSEd Maste
AproposAllSubCommands(llvm::StringRef prefix,llvm::StringRef search_word,StringList & commands_found,StringList & commands_help)327435933ddSDimitry Andric void CommandObjectProxy::AproposAllSubCommands(llvm::StringRef prefix,
328435933ddSDimitry Andric llvm::StringRef search_word,
329ac7ddfbfSEd Maste StringList &commands_found,
330435933ddSDimitry Andric StringList &commands_help) {
331ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
332ac7ddfbfSEd Maste if (proxy_command)
333435933ddSDimitry Andric return proxy_command->AproposAllSubCommands(prefix, search_word,
334435933ddSDimitry Andric commands_found, commands_help);
335ac7ddfbfSEd Maste }
336ac7ddfbfSEd Maste
LoadSubCommand(llvm::StringRef cmd_name,const lldb::CommandObjectSP & command_sp)337435933ddSDimitry Andric bool CommandObjectProxy::LoadSubCommand(
338435933ddSDimitry Andric llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_sp) {
339ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
340ac7ddfbfSEd Maste if (proxy_command)
341ac7ddfbfSEd Maste return proxy_command->LoadSubCommand(cmd_name, command_sp);
342ac7ddfbfSEd Maste return false;
343ac7ddfbfSEd Maste }
344ac7ddfbfSEd Maste
WantsRawCommandString()345435933ddSDimitry Andric bool CommandObjectProxy::WantsRawCommandString() {
346ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
347ac7ddfbfSEd Maste if (proxy_command)
348ac7ddfbfSEd Maste return proxy_command->WantsRawCommandString();
349ac7ddfbfSEd Maste return false;
350ac7ddfbfSEd Maste }
351ac7ddfbfSEd Maste
WantsCompletion()352435933ddSDimitry Andric bool CommandObjectProxy::WantsCompletion() {
353ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
354ac7ddfbfSEd Maste if (proxy_command)
355ac7ddfbfSEd Maste return proxy_command->WantsCompletion();
356ac7ddfbfSEd Maste return false;
357ac7ddfbfSEd Maste }
358ac7ddfbfSEd Maste
GetOptions()359435933ddSDimitry Andric Options *CommandObjectProxy::GetOptions() {
360ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
361ac7ddfbfSEd Maste if (proxy_command)
362ac7ddfbfSEd Maste return proxy_command->GetOptions();
3634bb0738eSEd Maste return nullptr;
364ac7ddfbfSEd Maste }
365ac7ddfbfSEd Maste
HandleCompletion(CompletionRequest & request)3664ba319b5SDimitry Andric int CommandObjectProxy::HandleCompletion(CompletionRequest &request) {
367ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
368ac7ddfbfSEd Maste if (proxy_command)
3694ba319b5SDimitry Andric return proxy_command->HandleCompletion(request);
370ac7ddfbfSEd Maste return 0;
371ac7ddfbfSEd Maste }
3724bb0738eSEd Maste
HandleArgumentCompletion(CompletionRequest & request,OptionElementVector & opt_element_vector)373435933ddSDimitry Andric int CommandObjectProxy::HandleArgumentCompletion(
3744ba319b5SDimitry Andric CompletionRequest &request, OptionElementVector &opt_element_vector) {
375ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
376ac7ddfbfSEd Maste if (proxy_command)
3774ba319b5SDimitry Andric return proxy_command->HandleArgumentCompletion(request, opt_element_vector);
378ac7ddfbfSEd Maste return 0;
379ac7ddfbfSEd Maste }
380ac7ddfbfSEd Maste
GetRepeatCommand(Args & current_command_args,uint32_t index)381435933ddSDimitry Andric const char *CommandObjectProxy::GetRepeatCommand(Args ¤t_command_args,
382435933ddSDimitry Andric uint32_t index) {
383ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
384ac7ddfbfSEd Maste if (proxy_command)
385ac7ddfbfSEd Maste return proxy_command->GetRepeatCommand(current_command_args, index);
3864bb0738eSEd Maste return nullptr;
387ac7ddfbfSEd Maste }
388ac7ddfbfSEd Maste
Execute(const char * args_string,CommandReturnObject & result)389435933ddSDimitry Andric bool CommandObjectProxy::Execute(const char *args_string,
390435933ddSDimitry Andric CommandReturnObject &result) {
391ac7ddfbfSEd Maste CommandObject *proxy_command = GetProxyCommandObject();
392ac7ddfbfSEd Maste if (proxy_command)
393ac7ddfbfSEd Maste return proxy_command->Execute(args_string, result);
394ac7ddfbfSEd Maste result.AppendError("command is not implemented");
395ac7ddfbfSEd Maste result.SetStatus(eReturnStatusFailed);
396ac7ddfbfSEd Maste return false;
397ac7ddfbfSEd Maste }
398