summaryrefslogtreecommitdiff
path: root/src/support/command-line.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/support/command-line.cpp')
-rw-r--r--src/support/command-line.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/support/command-line.cpp b/src/support/command-line.cpp
index f3b9ffe25..f1b4fca4d 100644
--- a/src/support/command-line.cpp
+++ b/src/support/command-line.cpp
@@ -37,8 +37,9 @@ void printWrap(std::ostream& os, int leftPad, const std::string& content) {
}
os << nextWord;
space -= nextWord.size() + 1;
- if (space > 0)
+ if (space > 0) {
os << ' ';
+ }
nextWord.clear();
if (content[i] == '\n') {
os << '\n';
@@ -56,8 +57,9 @@ Options::Options(const std::string& command, const std::string& description)
Arguments::Zero,
[this, command, description](Options* o, const std::string&) {
std::cout << command;
- if (positional != Arguments::Zero)
+ if (positional != Arguments::Zero) {
std::cout << ' ' << positionalName;
+ }
std::cout << "\n\n";
printWrap(std::cout, 0, description);
std::cout << "\n\nOptions:\n";
@@ -109,8 +111,9 @@ void Options::parse(int argc, const char* argv[]) {
size_t positionalsSeen = 0;
auto dashes = [](const std::string& s) {
for (size_t i = 0;; ++i) {
- if (s[i] != '-')
+ if (s[i] != '-') {
return i;
+ }
}
};
for (size_t i = 1, e = argc; i != e; ++i) {
@@ -147,9 +150,11 @@ void Options::parse(int argc, const char* argv[]) {
currentOption = currentOption.substr(0, equal);
}
Option* option = nullptr;
- for (auto& o : options)
- if (o.longName == currentOption || o.shortName == currentOption)
+ for (auto& o : options) {
+ if (o.longName == currentOption || o.shortName == currentOption) {
option = &o;
+ }
+ }
if (!option) {
std::cerr << "Unknown option '" << currentOption << "'\n";
exit(EXIT_FAILURE);
@@ -181,8 +186,9 @@ void Options::parse(int argc, const char* argv[]) {
break;
case Arguments::Optional:
if (!argument.size()) {
- if (i + 1 != e)
+ if (i + 1 != e) {
argument = argv[++i];
+ }
}
break;
}