Skip to content

Commit 20dc444

Browse files
Harmonize empty line in output of the cli
Signed-off-by: Volker Christian <me@vchrist.at>
1 parent 4e88222 commit 20dc444

5 files changed

Lines changed: 30 additions & 19 deletions

File tree

src/apps/http/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int main(int argc, char* argv[]) {
8484
{"snodec.home.vchrist.at", {{"Cert", cert}, {"CertKey", key}, {"CertKeyPassword", pass}}},
8585
{"www.vchrist.at", {{"Cert", cert}, {"CertKey", key}, {"CertKeyPassword", pass}}}};
8686

87-
webApp.getConfig().addSniCerts(sniCerts);
87+
// webApp.getConfig().addSniCerts(sniCerts);
8888
#endif
8989

9090
VLOG(1) << "Routes:";

src/net/rc/config/ConfigAddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace net::rc::config {
9696
"Channel number",
9797
"channel",
9898
"1",
99-
CLI::Range(1, 30));
99+
CLI::Range(static_cast<uint16_t>(1), static_cast<uint16_t>(30)));
100100
}
101101

102102
template <template <typename SocketAddress> typename ConfigAddressType>

src/utils/Config.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -678,16 +678,18 @@ namespace utils {
678678
try {
679679
confFile << app->config_to_str(true, true);
680680
confFile.close();
681-
out << Color::Code::FG_GREEN << "Error" << Color::Code::FG_DEFAULT
682-
<< "Writing config file: " + app->get_option_no_throw("--write-config")->as<std::string>();
681+
out << "[" << Color::Code::FG_GREEN << "SUCCESS" << Color::Code::FG_DEFAULT
682+
<< "] Writing config file: " + app->get_option_no_throw("--write-config")->as<std::string>() << std::endl
683+
<< std::endl;
683684
} catch (const CLI::ParseError& e) {
684685
confFile.close();
685-
out << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Writing config file: " << e.get_name() << " "
686-
<< e.what();
686+
out << "[" << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Writing config file: " << e.get_name() << " "
687+
<< e.what() << std::endl;
687688
}
688689
confFile.close();
689690
} else {
690-
out << "[" << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Writing config file: " << std::strerror(errno);
691+
out << "[" << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Writing config file: " << std::strerror(errno)
692+
<< std::endl;
691693
}
692694

693695
return out.str();
@@ -709,7 +711,7 @@ namespace utils {
709711
try {
710712
out << app->help(helpApp, "", mode);
711713
} catch (CLI::ParseError& e) {
712-
out << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Show help: " << e.get_name() << " " << e.what();
714+
out << "[" << Color::Code::FG_RED << "Error" << Color::Code::FG_DEFAULT << "] Show help: " << e.get_name() << " " << e.what();
713715
}
714716

715717
return out.str();
@@ -747,7 +749,7 @@ namespace utils {
747749
}
748750

749751
bool Config::parse2(bool parse1) {
750-
bool success = false;
752+
bool proceed = false;
751753

752754
try {
753755
try {
@@ -760,23 +762,23 @@ namespace utils {
760762

761763
if (!parse1) {
762764
if (showConfigTriggerApp != nullptr) {
763-
std::cout << getConfig(showConfigTriggerApp) << std::endl;
765+
std::cout << getConfig(showConfigTriggerApp);
764766
} else if (commandlineTriggerApp != nullptr) {
765-
std::cout << getCommandLine(commandlineTriggerApp) << std::endl;
767+
std::cout << getCommandLine(commandlineTriggerApp);
766768
} else if (app->get_option("--write-config")->count() > 0) {
767-
std::cout << doWriteConfig(app.get()) << std::endl;
769+
std::cout << doWriteConfig(app.get());
768770
} else {
769-
success = true;
771+
proceed = true;
770772
}
771773
} else {
772-
success = true;
774+
proceed = true;
773775
}
774776
} catch (const CLI::Success&) {
775777
if (!parse1) {
776778
throw;
777779
}
778780

779-
success = true;
781+
proceed = true;
780782
} catch (const CLI::ParseError& e) {
781783
if (helpTriggerApp != nullptr || showConfigTriggerApp != nullptr || commandlineTriggerApp != nullptr ||
782784
versionOpt->count() > 0) {
@@ -790,9 +792,9 @@ namespace utils {
790792
throw CLI::CallForHelp();
791793
}
792794
if (showConfigTriggerApp != nullptr) {
793-
std::cout << getConfig(showConfigTriggerApp) << std::endl;
795+
std::cout << getConfig(showConfigTriggerApp);
794796
} else if (commandlineTriggerApp != nullptr) {
795-
std::cout << getCommandLine(commandlineTriggerApp) << std::endl;
797+
std::cout << getCommandLine(commandlineTriggerApp);
796798
}
797799
} else {
798800
logger::Logger::setQuiet();
@@ -808,7 +810,7 @@ namespace utils {
808810
} catch (const DaemonSignaled& e) {
809811
std::cout << "Pid: " << getpid() << ", child pid: " << e.getPid() << ": " << e.what() << std::endl;
810812
} catch (const CLI::CallForHelp&) {
811-
std::cout << getHelp(app.get(), helpTriggerApp) << std::endl;
813+
std::cout << getHelp(app.get(), helpTriggerApp);
812814
} catch (const CLI::CallForVersion&) {
813815
std::cout << app->version() << std::endl << std::endl;
814816
} catch (const CLI::ConversionError& e) {
@@ -840,7 +842,7 @@ namespace utils {
840842
std::cout << std::endl << "Append -h or --help to your command line for more information." << std::endl;
841843
}
842844

843-
return success;
845+
return proceed;
844846
}
845847

846848
//////////////////

src/utils/Formatter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ namespace CLI {
284284
return out.str();
285285
}
286286

287+
CLI11_INLINE std::string HelpFormatter::make_footer(const App* app) const {
288+
std::string footer = app->get_footer();
289+
if (footer.empty()) {
290+
return std::string{"\n"};
291+
}
292+
return '\n' + footer + "\n\n";
293+
}
294+
287295
CLI11_INLINE std::string HelpFormatter::make_subcommands(const App* app, AppFormatMode mode) const {
288296
std::stringstream out;
289297

src/utils/Formatter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ namespace CLI {
9393
std::string make_group(std::string group, bool is_positional, std::vector<const Option*> opts) const override;
9494
std::string make_description(const App* app) const override;
9595
std::string make_usage(const App* app, std::string name) const override;
96+
std::string make_footer(const App* app) const override;
9697
std::string make_subcommands(const App* app, AppFormatMode mode) const override;
9798
std::string make_subcommand(const App* sub) const override;
9899
std::string make_expanded(const App* sub, AppFormatMode mode) const override;

0 commit comments

Comments
 (0)