From a995ef0d443f18462adaebeb8d3eaca1c3ccbae1 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Fri, 18 Jun 2021 15:23:02 +0200
Subject: [PATCH] cli default value handling

---
 examples/corsika.cpp | 3 ++-
 examples/mars.cpp    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/examples/corsika.cpp b/examples/corsika.cpp
index 078b9d2be..09e024287 100644
--- a/examples/corsika.cpp
+++ b/examples/corsika.cpp
@@ -156,7 +156,8 @@ int main(int argc, char** argv) {
   // parse the command line options into the variables
   CLI11_PARSE(app, argc, argv);
 
-  string const loglevel = app["verbosity"]->as<string>();
+  string const loglevel =
+      (app.count("--verbosity") ? app["verbosity"]->as<string>() : "info");
   if (loglevel == "warn") {
     logging::set_level(logging::level::warn);
   } else if (loglevel == "info") {
diff --git a/examples/mars.cpp b/examples/mars.cpp
index 0a9d7610b..73ca6fbf9 100644
--- a/examples/mars.cpp
+++ b/examples/mars.cpp
@@ -184,7 +184,8 @@ int main(int argc, char** argv) {
   // parse the command line options into the variables
   CLI11_PARSE(app, argc, argv);
 
-  string const loglevel = app["verbosity"]->as<string>();
+  string const loglevel =
+      (app.count("--verbosity") ? app["verbosity"]->as<string>() : "info");
   if (loglevel == "warn") {
     logging::set_level(logging::level::warn);
   } else if (loglevel == "info") {
-- 
GitLab