Example #1
0
	bool ConsoleCmd_Help::execute( Console & console , const std::vector< LocalizedString >& parameterList )
	{
		LocalizedStringStream helpText;

		if( parameterList.empty() )
		{
			// print all the command's help texts

			for( Console::CommandIndex::iterator it = console.m_commandIndex.begin(); it != console.m_commandIndex.end(); ++it )
			{
				const ConsoleCommandPtr command = it->second;
				GC_ASSERT_NOT_NULL( command.get() );

				printCommandHelp( helpText, console.commandCallPrefix(), command );
			}

		}
		else
		{
			// take the first parameter as the command name we want to print the help text of
			const ConsoleCommandPtr command = console.command( parameterList[0] );

			if( command )
			{
				// command found!
				printCommandHelp( helpText, console.commandCallPrefix(), command );
			}
			else
			{
				// command not found!
				helpText << L"Command not found : " <<  parameterList[0];
			}
		}

		console.printText( helpText.str() );

		return false;
	}