From 531dc99b593335b5ead52baa9d227f51d6e2ff6d Mon Sep 17 00:00:00 2001
From: David Parsons <david.parsons@inria.fr>
Date: Fri, 15 Dec 2023 16:03:18 +0100
Subject: [PATCH] get rid of global cmd-line option variables

# Conflicts:
#	src/aevol_create.cpp
---
 src/aevol_create.cpp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/aevol_create.cpp b/src/aevol_create.cpp
index 784399335..622c43a28 100644
--- a/src/aevol_create.cpp
+++ b/src/aevol_create.cpp
@@ -35,6 +35,7 @@
 #include <list>
 #include <sstream>
 #include <string>
+#include <tuple>
 
 #include "legacy/ExpManager.h"
 #include "aevol_version.h"
@@ -47,15 +48,11 @@ using namespace aevol;
 
 // Helper functions
 void print_help(char* prog_path);
-void interpret_cmd_line_options(int argc, char* argv[]);
+std::tuple<std::string, std::string> interpret_cmd_line_options(int argc, char* argv[]);
 std::list<std::string> read_sequence_file(const std::string& chromosome_file_name);
 
-// Command-line option variables
-static std::string param_file_name;
-static std::string chromosome_file_name;
-
 int main(int argc, char* argv[]) {
-  interpret_cmd_line_options(argc, argv);
+  const auto [param_file_name, chromosome_file_name] = interpret_cmd_line_options(argc, argv);
 
   // Print the hash and date of the commit used to compile this executable
   printf("Running aevol version %s\n", version_string);
@@ -124,7 +121,11 @@ void print_help(char* prog_path) {
   printf("\tload chromosome from given text file instead of generating it\n");
 }
 
-void interpret_cmd_line_options(int argc, char* argv[]) {
+std::tuple<std::string, std::string> interpret_cmd_line_options(int argc, char* argv[]) {
+  // Command-line option variables
+  std::string param_file_name;
+  std::string chromosome_file_name;
+
   // Define allowed options
   const char* options_list = "hVf:C:r:";
   static struct option long_options_list[] = {
@@ -168,6 +169,8 @@ void interpret_cmd_line_options(int argc, char* argv[]) {
   if (param_file_name.length() == 0) {
     param_file_name = DEFAULT_PARAM_FILE_NAME;
   }
+
+  return std::make_tuple(param_file_name, chromosome_file_name);
 }
 
 auto read_sequence(std::ifstream& chromosome_file, const std::string& chromosome_file_name) {
-- 
GitLab