| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 AdblockPlus::AppInfo appInfo; | 59 AdblockPlus::AppInfo appInfo; |
| 60 appInfo.version = "1.0"; | 60 appInfo.version = "1.0"; |
| 61 appInfo.name = "abpshell"; | 61 appInfo.name = "abpshell"; |
| 62 appInfo.application = "standalone"; | 62 appInfo.application = "standalone"; |
| 63 appInfo.applicationVersion = "1.0"; | 63 appInfo.applicationVersion = "1.0"; |
| 64 appInfo.locale = "en-US"; | 64 appInfo.locale = "en-US"; |
| 65 | 65 |
| 66 AdblockPlus::Platform platform; | 66 AdblockPlus::Platform platform; |
| 67 platform.SetUpJsEngine(appInfo); | 67 platform.SetUpJsEngine(appInfo); |
| 68 AdblockPlus::JsEngine& jsEngine = platform.GetJsEngine(); | 68 AdblockPlus::JsEngine& jsEngine = platform.GetJsEngine(); |
| 69 auto filterEngine = platform.GetFilterEngine(); | 69 auto& filterEngine = platform.GetFilterEngine(); |
| 70 | 70 |
| 71 CommandMap commands; | 71 CommandMap commands; |
| 72 Add(commands, new GcCommand(jsEngine)); | 72 Add(commands, new GcCommand(jsEngine)); |
| 73 Add(commands, new HelpCommand(commands)); | 73 Add(commands, new HelpCommand(commands)); |
| 74 Add(commands, new FiltersCommand(*filterEngine)); | 74 Add(commands, new FiltersCommand(filterEngine)); |
| 75 Add(commands, new SubscriptionsCommand(*filterEngine)); | 75 Add(commands, new SubscriptionsCommand(filterEngine)); |
| 76 Add(commands, new MatchesCommand(*filterEngine)); | 76 Add(commands, new MatchesCommand(filterEngine)); |
| 77 Add(commands, new PrefsCommand(*filterEngine)); | 77 Add(commands, new PrefsCommand(filterEngine)); |
| 78 | 78 |
| 79 std::string commandLine; | 79 std::string commandLine; |
| 80 while (ReadCommandLine(commandLine)) | 80 while (ReadCommandLine(commandLine)) |
| 81 { | 81 { |
| 82 std::string commandName; | 82 std::string commandName; |
| 83 std::string arguments; | 83 std::string arguments; |
| 84 ParseCommandLine(commandLine, commandName, arguments); | 84 ParseCommandLine(commandLine, commandName, arguments); |
| 85 const CommandMap::const_iterator it = commands.find(commandName); | 85 const CommandMap::const_iterator it = commands.find(commandName); |
| 86 try | 86 try |
| 87 { | 87 { |
| 88 if (it != commands.end()) | 88 if (it != commands.end()) |
| 89 (*it->second)(arguments); | 89 (*it->second)(arguments); |
| 90 else | 90 else |
| 91 throw NoSuchCommandError(commandName); | 91 throw NoSuchCommandError(commandName); |
| 92 } | 92 } |
| 93 catch (NoSuchCommandError error) | 93 catch (NoSuchCommandError error) |
| 94 { | 94 { |
| 95 std::cout << error.what() << std::endl; | 95 std::cout << error.what() << std::endl; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 catch (const std::exception& e) | 99 catch (const std::exception& e) |
| 100 { | 100 { |
| 101 std::cerr << "Exception: " << e.what() << std::endl; | 101 std::cerr << "Exception: " << e.what() << std::endl; |
| 102 } | 102 } |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| OLD | NEW |