Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5204 in orxonox.OLD for trunk/src/lib/shell/shell_command.cc


Ignore:
Timestamp:
Sep 18, 2005, 1:37:58 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: Shell now has a real nice help function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_command.cc

    r5203 r5204  
    212212    ShellCommandClass::commandClassList = new tList<ShellCommandClass>;
    213213    ShellCommand<ShellCommandBase>::registerCommand("debug", "ShellCommand", &ShellCommandBase::debugDyn);
     214  }
     215}
     216
     217void ShellCommandClass::help(const char* className)
     218{
     219  if (className == NULL)
     220    return;
     221  if (likely(ShellCommandClass::commandClassList != NULL))
     222  {
     223    tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();
     224    ShellCommandClass* elemCL = itCL->firstElement();
     225    while(elemCL != NULL)
     226    {
     227      if (elemCL->className && !strcasecmp(className, elemCL->className))
     228      {
     229        PRINT(0)("Class:'%s' registered %d commands: \n", elemCL->className, elemCL->commandList->getSize());
     230        tIterator<ShellCommandBase>* iterator = elemCL->commandList->getIterator();
     231        const ShellCommandBase* elem = iterator->firstElement();
     232        while(elem != NULL)
     233        {
     234          PRINT(0)("  command:'%s' : params:%d: ", elem->getName(), elem->paramCount);
     235          for (unsigned int i = 0; i< elem->paramCount; i++)
     236            PRINT(0)("%s ", ShellCommandBase::paramToString(elem->parameters[i]));
     237          if (elem->description != NULL)
     238            PRINT(0)("- %s", elem->description);
     239          PRINT(0)("\n");
     240          elem = iterator->nextElement();
     241        }
     242        delete iterator;
     243
     244        delete itCL;
     245        return;
     246      }
     247      elemCL = itCL->nextElement();
     248    }
     249    delete itCL;
     250    PRINTF(3)("Class %s not found in Command's classes\n", className);
     251  }
     252  else
     253  {
     254    PRINTF(1)("List of commandClasses does not exist");
    214255  }
    215256}
     
    413454          if (objectList != NULL)
    414455          {
    415             elemAL->getCommand()->executeCommand(objectList->firstElement(), executionString+inputSplits.getOffset(1));
     456            if (inputSplits.getCount() > 1)
     457              elemAL->getCommand()->executeCommand(objectList->firstElement(), executionString+inputSplits.getOffset(1));
     458            else
     459              elemAL->getCommand()->executeCommand(objectList->firstElement(), "");
    416460            delete itAL;
    417461            return true;
     
    441485      delete itCL;
    442486    }
    443 
    444487
    445488    if (classID != CL_NULL && inputSplits.getCount() >= 2 && objectList != NULL)
     
    484527        }
    485528        delete itCMD;
    486 
    487       }
    488 
    489     }
    490 
    491 
    492   }
    493 
     529      }
     530    }
     531  }
    494532}
    495533
Note: See TracChangeset for help on using the changeset viewer.