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: Reduce redundant redundancy Created March 27, 2013, 6:45 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
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))
+ {
Felix Dahlke 2013/03/27 08:18:26 This whole block is an unrelated indentation chang
+ 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)
{
« shell/src/Command.h ('K') | « shell/src/Command.cpp ('k') | shell/src/MatchesCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld