/* * px * Copyright (c) 2008 Shawn Hladky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "pxheaders.h" #include "pxclient.h" #include "commands/extendedcommands.h" #include "commands/helpcommand.h" pxClient::~pxClient() { //delete _argv; } void pxClient::SetArgv( int argc, char *const *argv ) { for (int i=0; i < argc; i++) { _args.Put()->Set(argv[i]); } } void pxClient::AddArg(const char* arg) { _args.Put()->Set(arg); } // // Look for an extended command and run it if found. // void pxClient::Run( const char *func, bool tagged, bool CaseSensitive, int ServerLevel, ClientUser* ui ) { //ClientApi api; StrRef cmd( func ); pxBaseCommand* command = 0; // spin through the extended commands and see if we have a match for (int i=0; i < N_COMMANDS; i++) { if (cmd.Compare(*ExtendedCommands[i]->CommandString()) == 0) { command = ExtendedCommands[i]; } } if (command) { if (tagged) command->SetTag(); if (CaseSensitive) command->SetNoCase(); command->SetServerLevel(ServerLevel); // convert args to a char* [] const StrBuf* arg; char** argv = new char* [_args.Count()]; for(int i = 0; arg = _args.Get(i); i++) { argv[i] = arg->Text(); } // We have an extended command, run it command->Run(ui, this, argv, _args.Count()); } else if (cmd == "help") { // we have special handling for help const StrBuf* arg; char** argv = new char* [_args.Count()]; for(int i = 0; arg = _args.Get(i); i++) { argv[i] = arg->Text(); } helpCommand hc; hc.Run(ui, this, argv, _args.Count()); } else // standard Perforce command { const StrBuf* arg; for(int i = 0; arg = _args.Get(i); i++) { //printf("arg: %s\n", arg->Text()); StrDict::SetVar("", arg); } // Standard command, run ClientApi::Run( func, ui ); } // clear the arg vector for the next command int numArgs = _args.Count(); for(int i = 0; i < numArgs ; i++) { //printf("remove arg: %s\n", _args.Get(0)->Text()); _args.Remove(0); } return; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 6351 | Shawn Hladky |
px: fixing -X flag. fixing help commands |
||
#3 | 6348 | Shawn Hladky | px: fixing -x flag for extended commands | ||
#2 | 6332 | Shawn Hladky |
px: Updates to build script. Trying to fix -x option (still not right) Fix api download script |
||
#1 | 6308 | Shawn Hladky | px: Initial submit |