-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdline.cpp
43 lines (37 loc) · 1021 Bytes
/
cmdline.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
#include "semverutil/cmdline.hpp"
namespace semver
{
auto parse_cmdline(std::span<char const*> cmdline) noexcept
-> ParseCmdLineResult
{
std::uint32_t opts = 0;
std::vector<std::string_view> args;
for (auto param : cmdline) {
if (*param == '\0')
break;
if (*param == '+') {
args.push_back(param);
continue;
}
if (*param++ != '-')
continue;
for (; *param != '\0'; ++param) {
switch (*param) {
case 'M':
opts |= CmdLineSwitches::increment_major;
break;
case 'N':
opts |= CmdLineSwitches::increment_minor;
break;
case 'P':
opts |= CmdLineSwitches::increment_patch;
break;
case 'R':
opts |= CmdLineSwitches::increment_revision;
break;
}
}
}
return { opts, std::move(args) };
}
} // namespace semver