Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: shell/src/Main.cpp

Issue 9987009: Interface for the libadblockplus API (Closed)
Patch Set: Use new API in the shell Created March 27, 2013, 4:58 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « shell/src/Command.cpp ('k') | shell/src/MatchesCommand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/src/Main.cpp
===================================================================
--- a/shell/src/Main.cpp
+++ b/shell/src/Main.cpp
@@ -60,34 +60,33 @@
LibFileReader fileReader;
CerrErrorCallback errorCallback;
AdblockPlus::JsEngine jsEngine(&fileReader, 0);
- jsEngine.Load("adblockplus_compat.js");
- jsEngine.Load("adblockplus.js");
+ AdblockPlus::FilterEngine filterEngine(jsEngine);
CommandMap commands;
Add(commands, new GcCommand(jsEngine));
Add(commands, new HelpCommand(commands));
- Add(commands, new SubscriptionsCommand(jsEngine));
- Add(commands, new MatchesCommand());
+ Add(commands, new SubscriptionsCommand(filterEngine));
+ Add(commands, new MatchesCommand(filterEngine));
std::string commandLine;
while (ReadCommandLine(commandLine))
+ {
+ std::string commandName;
+ std::string arguments;
+ ParseCommandLine(commandLine, commandName, arguments);
+ const CommandMap::const_iterator it = commands.find(commandName);
+ try
{
- std::string commandName;
- std::string arguments;
- ParseCommandLine(commandLine, commandName, arguments);
- const CommandMap::const_iterator it = commands.find(commandName);
- try
- {
- if (it != commands.end())
- (*it->second)(arguments);
- else
- throw NoSuchCommandError(commandName);
- }
- catch (NoSuchCommandError error)
- {
- std::cout << error.what() << std::endl;
- }
+ if (it != commands.end())
+ (*it->second)(arguments);
+ else
+ throw NoSuchCommandError(commandName);
}
+ catch (NoSuchCommandError error)
+ {
+ std::cout << error.what() << std::endl;
+ }
+ }
}
catch (const std::exception& e)
{
« no previous file with comments | « shell/src/Command.cpp ('k') | shell/src/MatchesCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld