- }
- } else if ( command == "pwd" ) {
- string ttt = node->getPath();
- if ( ttt == "" ) {
- ttt = "/";
- }
- ttt += "\n";
- io->writestring( ttt.c_str() );
- } else if ( command == "get" || command == "show" ) {
- if ( tokens.size() <= 1 ) {
- // do nothing
- } else {
- string ttt = "debug = '" + tokens[1] + "'\n";
- io->writestring( ttt.c_str() );
-
- string value = node->getStringValue ( tokens[1], "" );
- string tmp = tokens[1] + " = '" + value + "' (";
- tmp += getValueTypeString( node->getValue( tokens[1] ) );
- tmp += ")\n";
-
- io->writestring( tmp.c_str() );
- }
- } else if ( command == "set" ) {
- if ( tokens.size() <= 2 ) {
- // do nothing
+ } else if ( command == "set" ) {
+ if ( tokens.size() >= 2 ) {
+ string value, tmp;
+ if ( tokens.size() == 3 ) {
+ value = tokens[2];
+ } else {
+ value = "";
+ }
+ node->getNode( tokens[1].c_str(), true )
+ ->setStringValue(value.c_str());
+
+ if ( mode == PROMPT ) {
+ // now fetch and write out the new value as confirmation
+ // of the change
+ value = node->getStringValue ( tokens[1].c_str(), "" );
+ tmp = tokens[1] + " = '" + value + "' (";
+ tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
+ tmp += ")";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ }
+ } else if ( command == "reinit" ) {
+ if ( tokens.size() == 2 ) {
+ string tmp;
+ SGPropertyNode args;
+ for ( unsigned int i = 1; i < tokens.size(); ++i ) {
+ cout << "props: adding subsystem = " << tokens[i] << endl;
+ SGPropertyNode *node = args.getNode("subsystem", i-1, true);
+ node->setStringValue( tokens[i].c_str() );
+ }
+ if ( !globals->get_commands()
+ ->execute( "reinit", &args) )
+ {
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "Command " << tokens[1] << " failed.");
+ if ( mode == PROMPT ) {
+ tmp += "*failed*";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ } else {
+ if ( mode == PROMPT ) {
+ tmp += "<completed>";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ }
+ }
+ } else if ( command == "run" ) {
+ string tmp;
+ if ( tokens.size() >= 2 ) {
+ SGPropertyNode args;
+ if ( tokens[1] == "reinit" ) {
+ for ( unsigned int i = 2; i < tokens.size(); ++i ) {
+ cout << "props: adding subsystem = " << tokens[i]
+ << endl;
+ SGPropertyNode *node
+ = args.getNode("subsystem", i-2, true);
+ node->setStringValue( tokens[i].c_str() );
+ }
+ } else if ( tokens[1] == "set-sea-level-air-temp-degc" ) {
+ for ( unsigned int i = 2; i < tokens.size(); ++i ) {
+ cout << "props: set-sl command = " << tokens[i]
+ << endl;
+ SGPropertyNode *node
+ = args.getNode("temp-degc", i-2, true);
+ node->setStringValue( tokens[i].c_str() );
+ }
+ } else if ( tokens[1] == "set-outside-air-temp-degc" ) {
+ for ( unsigned int i = 2; i < tokens.size(); ++i ) {
+ cout << "props: set-oat command = " << tokens[i]
+ << endl;
+ SGPropertyNode *node
+ = args.getNode("temp-degc", i-2, true);
+ node->setStringValue( tokens[i].c_str() );
+ }
+ } else if ( tokens[1] == "timeofday" ) {
+ for ( unsigned int i = 2; i < tokens.size(); ++i ) {
+ cout << "props: time of day command = " << tokens[i]
+ << endl;
+ SGPropertyNode *node
+ = args.getNode("timeofday", i-2, true);
+ node->setStringValue( tokens[i].c_str() );
+ }
+ }
+ if ( !globals->get_commands()
+ ->execute(tokens[1].c_str(), &args) )
+ {
+ SG_LOG( SG_GENERAL, SG_ALERT,
+ "Command " << tokens[1] << " failed.");
+ if ( mode == PROMPT ) {
+ tmp += "*failed*";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ } else {
+ if ( mode == PROMPT ) {
+ tmp += "<completed>";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ }
+ } else {
+ if ( mode == PROMPT ) {
+ tmp += "no command specified";
+ push( tmp.c_str() );
+ push( getTerminator() );
+ }
+ }
+ } else if (command == "quit") {
+ close();
+ shouldDelete();
+ return;
+ } else if ( command == "data" ) {
+ mode = DATA;
+ } else if ( command == "prompt" ) {
+ mode = PROMPT;