Skip to content

Commit 4de5a85

Browse files
Add simplified CLI parsing for version flag
1 parent 88c9683 commit 4de5a85

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

cli/main.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
#include <cstring>
12
#include <iostream>
3+
#include <string_view>
24
#include <utility>
35

46
#include "perf_event.hpp"
57

68
using namespace cpuscope;
79

8-
int main(int /*argc*/, char** /*argv[]*/)
10+
static constexpr std::string_view VERSION = "0.1.0";
11+
12+
int main(int argc, char** argv)
913
{
14+
// Simplified parsing of command-line arguments for demonstration purposes
15+
// Later add a cli lib like CLI11 or cxxopts for more robust argument parsing
16+
for (int i = 1; i < argc; ++i)
17+
{
18+
if (std::strcmp(argv[i], "--version") == 0)
19+
{
20+
std::cout << "cpu_scope version " << VERSION << '\n';
21+
return 0;
22+
}
23+
}
24+
1025
PerfEvent::LinuxSysCalls sysCalls;
1126
PerfEvent::Config config;
1227
config.scope = PerfEvent::Scope::CPU;

0 commit comments

Comments
 (0)