MCPcopy Create free account
hub / github.com/SoarGroup/Soar / HandleCommandLine

Method HandleCommandLine

Core/KernelSML/src/sml_KernelSMLHandlers.cpp:895–1035  ·  view source on GitHub ↗

Executes a generic command line for a specific agent

Source from the content-addressed store, hash-verified

893
894// Executes a generic command line for a specific agent
895bool KernelSML::HandleCommandLine(AgentSML* pAgentSML, char const* pCommandName, Connection* pConnection, AnalyzeXML* pIncoming, soarxml::ElementXML* pResponse)
896{
897#ifdef _DEBUG
898 bool kDebugCommandLine = false ;
899#else
900 bool kDebugCommandLine = false ;
901#endif
902
903 // Get the parameters
904 char const* pLine = pIncoming->GetArgString(sml_Names::kParamLine) ;
905 bool echoResults = pIncoming->GetArgBool(sml_Names::kParamEcho, false) ;
906 bool noFiltering = pIncoming->GetArgBool(sml_Names::kParamNoFiltering, false) ;
907
908 // If the user chooses to enable this feature, certain commands are always echoed back.
909 // This is primarily to support two users connected to and debugging the same kernel at once.
910 if (GetEchoCommands() && m_CommandLineInterface.ShouldEchoCommand(pLine))
911 {
912 echoResults = true ;
913 }
914
915 bool rawOutput = false;
916
917 // The caller can ask for simple string output (raw output) or more complex, structured XML output
918 // which can then be parsed.
919 soarxml::ElementXML const* pCommand = pIncoming->GetCommandTag() ;
920 const char* pCommandOutput = pCommand->GetAttribute(sml_Names::kCommandOutput) ;
921
922 if (pCommandOutput)
923 {
924 rawOutput = (strcmp(pCommandOutput, sml_Names::kRawOutput) == 0) ;
925 }
926
927 if (!pLine)
928 {
929 return InvalidArg(pConnection, pResponse, pCommandName, "Command line missing") ;
930 }
931
932 if (kDebugCommandLine)
933 {
934 sml::PrintDebugFormat("Executing %s", pLine) ;
935 }
936
937 // If we're echoing the results, also echo the command we're executing
938 if (echoResults && pAgentSML)
939 {
940 pAgentSML->FireEchoEvent(pConnection, pLine) ;
941 }
942
943 if (kDebugCommandLine)
944 {
945 sml::PrintDebugFormat("Echoed line\n") ;
946 }
947
948 // Send this command line through anyone registered filters.
949 // If there are no filters (or this command requested not to be filtered), this copies the original line into the filtered line unchanged.
950 char const* pFilteredLine = pLine ;
951 bool filteredError = false ;
952 soarxml::ElementXML* pFilteredXML = NULL ;

Callers

nothing calls this directly

Calls 13

SendFilterMessageMethod · 0.95
ReturnResultMethod · 0.95
GetEchoCommandsFunction · 0.85
GetArgStringMethod · 0.80
ShouldEchoCommandMethod · 0.80
GetCommandTagMethod · 0.80
SetCommandMethod · 0.80
DoCommandMethod · 0.80
ParseXMLFromStringFunction · 0.50
GetArgBoolMethod · 0.45
GetAttributeMethod · 0.45
GenerateXMLStringMethod · 0.45

Tested by

no test coverage detected