-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
50 lines (35 loc) · 1.3 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "pch.h"
#include "helpers.h"
#include "code_size_result.h"
#include "code_type.h"
#include "code_type_cpp.h"
#include "user_ignored_files.h"
#include <CLI11.hpp> // 3rdParty
int main(int argc, char *argv[])
{
CLI::App cliApp{ "codesize" };
string_list targetPaths;
cliApp.add_option("paths", targetPaths, "The paths to process. Default is current directory if none are provided.");
// Add the --skip option
std::string userSkip;
cliApp.add_option("--skip", userSkip, "Comma-separated list of files to skip.");
// Add the --verbose switch
bool verbose = false;
cliApp.add_flag("--verbose", verbose, "Enable verbose output.");
// Parse command-line arguments
CLI11_PARSE(cliApp, argc, argv);
// If no paths provided, default to the current directory
if (targetPaths.empty())
targetPaths = { std::filesystem::current_path().string() };
CodeType* pCodeType = nullptr;
UserIgnoredFiles userIgnored(userSkip);
pCodeType = new CodeTypeCpp(); // TODO: add others, choose from command line
CodeSizeResult resultTotal;
for (const auto & path : targetPaths)
{
resultTotal += pCodeType->processDirectory(path, &userIgnored, verbose);
}
resultTotal.print(pCodeType->getName());
delete pCodeType;
return 0;
}