/* * PVVMUD a 3D MUD * Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <string.h> #include <stdlib.h> #include "pvvmud.H" #include "pvvmudclient.H" CCliCmdParser::CCliCmdParser(CPvvmudClient * client): CCommandParser() { m_client = client; setCommandPrefix('!'); addCommand("help",(CommandFunc_t)&commandHelp); addCommand("dump",(CommandFunc_t)&commandDump); } CCliCmdParser::~CCliCmdParser(){ } void CCliCmdParser::printMsg(const string & msg){ m_client->getConsole()->addMsg((char*)msg.c_str()); } void CCliCmdParser::commandUnknown(const string & commandString){ printMsg("Unkown command: " + commandString + "\n"); } void CCliCmdParser::commandChat(const string & chatMessage){ m_client->getManager()->sendMsg(chatMessage.c_str()); } /////////////////////////////////////////////////////////////////////////////// // commandHelp // Syntax: /help [command] /////////////////////////////////////////////////////////////////////////////// void CCliCmdParser::commandHelp(argv_t & argv){ if (argv.size() == 2){ if (argv[1] == "help"){ printMsg( "help [<command>]\n" " Use this command to get help.\n" ); } else if (argv[1] == "dump"){ printMsg( "dump [ screen | world ]\n" " screen : Dump screen to file \"pvvmudscreen.tif\"\n" " world : Dump world hiearchy to stdout.\n" ); } else { printMsg( "Unkown kommand\n" ); } } else { printMsg( "Help\n" " Client commands start with '!'\n" " Commands:\n" " !help\n" " !dump\n" " Use !help <command> for help about a command\n" ); } } /////////////////////////////////////////////////////////////////////////////// // commandDump /////////////////////////////////////////////////////////////////////////////// void CCliCmdParser::commandDump(argv_t & argv){ if (argv[1] == "screen"){ // m_client->getInputFunction()->executeFunction("capture"); m_client->getInputFunction()->executeFunction("key_c"); } else if (argv[1] == "world"){ // m_client->getInputFunction()->executeFunction("dump"); m_client->getInputFunction()->executeFunction("key_d"); } else { parseCommand("!help dump"); } }