| 149 | {} |
| 150 | |
| 151 | bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) |
| 152 | { |
| 153 | const Result result = parseFromArgs(argc, argv); |
| 154 | |
| 155 | switch (result) { |
| 156 | case Result::Success: |
| 157 | break; |
| 158 | case Result::Exit: |
| 159 | Settings::terminate(); |
| 160 | return true; |
| 161 | case Result::Fail: |
| 162 | return false; |
| 163 | } |
| 164 | |
| 165 | // Libraries must be loaded before FileLister is executed to ensure markup files will be |
| 166 | // listed properly. |
| 167 | if (!loadLibraries(mSettings)) |
| 168 | return false; |
| 169 | |
| 170 | if (!loadAddons(mSettings)) |
| 171 | return false; |
| 172 | |
| 173 | // Check that all include paths exist |
| 174 | { |
| 175 | for (auto iter = mSettings.includePaths.cbegin(); |
| 176 | iter != mSettings.includePaths.cend(); |
| 177 | ) { |
| 178 | const std::string path(Path::toNativeSeparators(*iter)); |
| 179 | if (Path::isDirectory(path)) |
| 180 | ++iter; |
| 181 | else { |
| 182 | // TODO: this bypasses the template format and other settings |
| 183 | // If the include path is not found, warn user and remove the non-existing path from the list. |
| 184 | if (mSettings.severity.isEnabled(Severity::information)) |
| 185 | std::cout << "(information) Couldn't find path given by -I '" << path << '\'' << std::endl; |
| 186 | iter = mSettings.includePaths.erase(iter); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | // Output a warning for the user if he tries to exclude headers |
| 192 | const std::vector<std::string>& ignored = mIgnoredPaths; |
| 193 | const bool warn = std::any_of(ignored.cbegin(), ignored.cend(), [](const std::string& i) { |
| 194 | return Path::isHeader(i); |
| 195 | }); |
| 196 | if (warn) { |
| 197 | mLogger.printMessage("filename exclusion does not apply to header (.h and .hpp) files."); |
| 198 | mLogger.printMessage("Please use --suppress for ignoring results from the header files."); |
| 199 | } |
| 200 | |
| 201 | const std::vector<std::string>& pathnamesRef = mPathNames; |
| 202 | const std::list<FileSettings>& fileSettingsRef = mFileSettings; |
| 203 | |
| 204 | // the inputs can only be used exclusively - CmdLineParser should already handle this |
| 205 | assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty())); |
| 206 | |
| 207 | if (!fileSettingsRef.empty()) { |
| 208 | std::list<FileSettings> fileSettings; |
no test coverage detected