Skip to content

Commit

Permalink
WIP: initial draft for server cli refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
WOLFI3654 committed Oct 21, 2023
1 parent ccb9e45 commit 275f275
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/murmur/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include "ServerDB.h"
#include "Version.h"

#include <boost/optional.hpp>
#include <boost/optional/optional_io.hpp>
#include <boost/tuple/tuple_io.hpp>
#include <boost/logic/tribool.hpp>
#include <csignal>
#include <iostream>
Expand Down Expand Up @@ -208,7 +209,7 @@ auto parseCLI(int argc, char **argv) {
struct {
bool quit = false;
boost::optional< std::string > ini_file;
boost::optional< std::tuple< std::string, int > > supw_srv;
boost::tuple<std::string, boost::optional<int>> supw_srv;
boost::optional< int > disable_su_srv;
bool verbose_logging = false;
#ifdef QT_NO_DEBUG
Expand All @@ -233,9 +234,10 @@ auto parseCLI(int argc, char **argv) {
->option_text("<inifile>")
->expected(1, 2)
->check(CLI::ExistingFile);
app.add_option_no_stream("-w,--supw", options.supw_srv, "Set password for 'SuperUser' account on server srv.")
app.add_option("-w,--supw", options.supw_srv, "Set password for 'SuperUser' account on server srv.")
->option_text("<pw> [srv]")
->expected(1, 2);
->allow_extra_args()
->expected(0, 1);
#ifdef Q_OS_UNIX
app.add_option_no_stream("-r,--readsupw", options.read_supw_srv,
"Reads password for server srv from standard input.")
Expand All @@ -250,7 +252,6 @@ auto parseCLI(int argc, char **argv) {
app.add_option_no_stream("-d,--disablesu", options.disable_su_srv,
"Disable password for 'SuperUser' account on server srv.")
->option_text("[srv]")
->default_val(1)
->expected(0, 1);
app.add_flag("-b,--verbose", options.verbose_logging, "Use verbose logging (include debug-logs).");
app.add_flag("!-f,!--force-fg", options.detach,
Expand Down Expand Up @@ -384,10 +385,9 @@ int main(int argc, char **argv) {
sunum = cli_options.disable_su_srv.get();
}

if (cli_options.supw_srv.has_value()) {
auto tuple = cli_options.supw_srv.get();
supw = QString::fromStdString(std::get< 0 >(tuple));
sunum = std::get< 1 >(tuple);
if (!cli_options.supw_srv.get<0>().empty()) {
supw = QString::fromStdString(cli_options.supw_srv.get<0>());
sunum = cli_options.supw_srv.get<1>().get_value_or(1);
#ifdef Q_OS_LINUX
} else if (cli_options.read_supw_srv.has_value()) {
// Note that it is essential to set detach = false here. If this is ever to be changed, the code part
Expand Down

0 comments on commit 275f275

Please sign in to comment.