31 std::map<std::string, Command*> CommandHandler::mCommandMap = std::map<std::string, Command*>();
33 void CommandHandler::registerAampcliCommands()
35 registerAllCommands();
36 registerCommandObjects();
39 void CommandHandler::registerCommandObjects()
41 registerCommand(
"set",
new Set);
42 registerCommand(
"get",
new Get);
43 registerCommand(
"harvest",
new Harvestor);
44 registerCommand(
"smoketest",
new SmokeTest);
48 void CommandHandler::registerCommand(
const std::string& commandName,
Command* command)
50 std::map<std::string, Command*>::iterator cmdPair = mCommandMap.find(commandName);
51 if (cmdPair != mCommandMap.end())
53 printf(
"%s:%d: Command already registered\n", __FUNCTION__, __LINE__);
57 mCommandMap[commandName] = command;
61 bool CommandHandler::dispatchAampcliCommands(
char *cmd,
PlayerInstanceAAMP *playerInstanceAamp)
64 char l_cmd[4096] = {
'\0'};
66 char *token = strtok(l_cmd,
" ");
70 std::map<std::string, Command*>::iterator cmdPair;
71 cmdPair = mCommandMap.find(token);
73 if(cmdPair == mCommandMap.end())
75 cmdPair = mCommandMap.find(
"default");
78 Command* l_Command = cmdPair->second;
79 l_status = l_Command->execute(cmd,playerInstanceAamp);
86 void CommandHandler::registerAllCommands()
92 lPlaybackCommand.registerPlaybackCommands();
98 char ** CommandHandler::commandCompletion(
const char *text,
int start,
int end)
104 char *buffer = rl_line_buffer;
106 rl_attempted_completion_over = 1;
108 if(strncmp(buffer,
"get", 3) == 0)
110 return rl_completion_matches(text, lGet.getCommandRecommender);
112 else if (strncmp(buffer,
"set", 3) == 0)
114 return rl_completion_matches(text, lSet.setCommandRecommender);
118 return rl_completion_matches(text, lPlaybackCommand.commandRecommender);