aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/configuration/configuration.cpp19
-rw-r--r--lib/configuration/configuration.h29
2 files changed, 24 insertions, 24 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index 1829a5e..def997d 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -45,6 +45,7 @@ Configuration::Configuration()
commandLine_desc.add_options()
("help,h", "Display this help.")
("version,v", "Display version information.")
+ ("build", "Display build branch and commit.")
("config,c", po::value<std::string>()->default_value(defaultUserConfigLocation()), "Set the configuration file.")
("socket,s", po::value<std::string>()->default_value(defaultSocketPath()), "Local server socket")
@@ -122,7 +123,7 @@ Configuration::Configuration()
Configuration::~Configuration() = default;
-bool Configuration::parseConfigFile(const std::string &path)
+bool Configuration::parse(const std::string &path)
{
std::ifstream f(path, std::ifstream::in);
@@ -131,7 +132,7 @@ bool Configuration::parseConfigFile(const std::string &path)
return true;
}
-bool Configuration::parseCommandLine(int argc, char **argv)
+bool Configuration::parse(int argc, char **argv)
{
try {
auto cmd = po::command_line_parser(argc, argv);
@@ -145,20 +146,6 @@ bool Configuration::parseCommandLine(int argc, char **argv)
return false;
}
- if(vm.count("help")) {
- std::cout << qUtf8Printable(qApp->applicationName()) << " " << qUtf8Printable(qApp->applicationVersion()) << ": yet another no-frills browser" << std::endl;
- std::cout << "Usage: " << qUtf8Printable(qApp->arguments().at(0)) << " [options] URL(s)" << std::endl;
-
- std::cout << std::endl << "Command-line Options: " << std::endl << commandLine_desc << std::endl;
- std::cout << std::endl << "Configuration Options: " << std::endl << configuration_desc << std::endl;
- exit(0);
- }
-
- if(vm.count("version")) {
- std::cout << qUtf8Printable(qApp->applicationName()) << " " << qUtf8Printable(qApp->applicationVersion()) << std::endl;
- exit(0);
- }
-
return true;
}
diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h
index af75122..1d0fb54 100644
--- a/lib/configuration/configuration.h
+++ b/lib/configuration/configuration.h
@@ -23,8 +23,17 @@ public:
explicit Configuration();
~Configuration();
- bool parseConfigFile(const std::string &path);
- bool parseCommandLine(int argc, char **argv);
+ bool parse(const std::string &path);
+ bool parse(int argc, char **argv);
+
+ const std::vector<boost::shared_ptr<boost::program_options::option_description>> &options()
+ {
+ return configuration_desc.options();
+ }
+
+ bool exists(const char *path) {
+ return vm.count(path) ? true : false;
+ }
template <typename T>
std::optional<T> value(const char *path) const
@@ -64,12 +73,6 @@ public:
return std::optional<T>(vm[path].as<T>());
}
- const std::vector<boost::shared_ptr<boost::program_options::option_description>> &options()
- {
- return configuration_desc.options();
- }
-
- QHash<QString, QString> section(const std::string &prefix) const;
QStringList positionalArguments() const
{
QStringList l;
@@ -82,6 +85,16 @@ public:
return l;
}
+ QHash<QString, QString> section(const std::string &prefix) const;
+ const boost::program_options::options_description commandlineOptions() const
+ {
+ return commandLine_desc;
+ }
+ const boost::program_options::options_description configurationOptions() const
+ {
+ return configuration_desc;
+ }
+
private:
boost::program_options::options_description commandLine_desc;
boost::program_options::options_description configuration_desc;