From 059e938359507016d0c176fa9ba977ffefefb439 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Fri, 15 Apr 2016 09:19:30 +0200
Subject: [PATCH] include command string in exception

---
 aarbology2/src/aarbology.cpp                  |  3 ++
 acast2/src/acast.cpp                          |  3 ++
 acompaction2/src/acompaction.cpp              |  4 ++-
 acompare2/src/acompare.cpp                    |  3 +-
 aconversions2/src/aconversion.cpp             |  6 ++--
 aconvert2/src/aconvert.cpp                    |  3 ++
 aderivation2/src/aderivation.cpp              |  3 ++
 adeterminize2/src/adeterminize.cpp            |  3 ++
 aecho2/src/aecho.cpp                          |  3 ++
 aepsilon2/src/aepsilon.cpp                    |  4 ++-
 agenerate2/src/agenerate.cpp                  |  3 ++
 agraphbench2/src/agraphbench.cpp              |  3 ++
 aintegral2/src/aintegral.cpp                  |  3 ++
 alangop2/src/alangop.cpp                      |  3 ++
 alib2common/src/exception/CommonException.cpp | 29 ++++++++++++-------
 alib2common/src/exception/CommonException.h   |  5 ++--
 alib2common/src/sax/ComposerException.cpp     |  5 +---
 alib2common/src/sax/ParserException.cpp       |  5 +---
 alib2data/src/alphabet/SymbolException.cpp    |  3 --
 alib2data/src/alphabet/SymbolException.h      |  1 -
 .../src/automaton/AutomatonException.cpp      |  3 --
 alib2data/src/automaton/AutomatonException.h  |  1 -
 alib2data/src/grammar/GrammarException.cpp    |  3 --
 alib2data/src/grammar/GrammarException.h      |  1 -
 alib2data/src/tree/TreeException.cpp          |  3 --
 alib2data/src/tree/TreeException.h            |  1 -
 alphabetManip2/src/alphabetManip.cpp          |  3 ++
 ameasure2/src/ameasure.cpp                    | 13 +++++++--
 ameasurep2/src/ameasureproc.cpp               | 13 +++++++--
 aminimize2/src/aminimize.cpp                  |  4 ++-
 anormalize2/src/anormalize.cpp                |  4 ++-
 arand2/src/arand.cpp                          |  3 ++
 araw2/src/araw.cpp                            |  3 ++
 arename2/src/arename.cpp                      |  4 ++-
 areverse2/src/areverse.cpp                    |  4 ++-
 arun2/src/arun.cpp                            |  3 ++
 astat2/src/astat.cpp                          |  3 ++
 astringology2/src/astringology.cpp            |  3 ++
 atrim2/src/atrim.cpp                          |  3 ++
 tniceprint/src/tniceprint.cpp                 |  3 ++
 40 files changed, 122 insertions(+), 51 deletions(-)

diff --git a/aarbology2/src/aarbology.cpp b/aarbology2/src/aarbology.cpp
index d8a19530ec..6752b0a903 100644
--- a/aarbology2/src/aarbology.cpp
+++ b/aarbology2/src/aarbology.cpp
@@ -32,6 +32,9 @@
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Arbology algorithm access binary", ' ', "0.01" );
 
 		std::vector < std::string > allowed;
diff --git a/acast2/src/acast.cpp b/acast2/src/acast.cpp
index 6e1bce8bd8..caea20f99e 100644
--- a/acast2/src/acast.cpp
+++ b/acast2/src/acast.cpp
@@ -19,6 +19,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("cast binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to echo",	false,	"-",		"file");
diff --git a/acompaction2/src/acompaction.cpp b/acompaction2/src/acompaction.cpp
index 794037d07d..3678758241 100644
--- a/acompaction2/src/acompaction.cpp
+++ b/acompaction2/src/acompaction.cpp
@@ -15,8 +15,10 @@
 #include "automaton/transform/Compaction.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton compaction binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to compactify",		false,	"-",		"file");
diff --git a/acompare2/src/acompare.cpp b/acompare2/src/acompare.cpp
index 36ee75972f..117b919781 100644
--- a/acompare2/src/acompare.cpp
+++ b/acompare2/src/acompare.cpp
@@ -17,8 +17,9 @@
 #include "GrammarCompare.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
 
 		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01");
 
diff --git a/aconversions2/src/aconversion.cpp b/aconversions2/src/aconversion.cpp
index cd68615cc8..29ccd7d839 100644
--- a/aconversions2/src/aconversion.cpp
+++ b/aconversions2/src/aconversion.cpp
@@ -15,9 +15,11 @@
 
 #include "ConversionHandler.h"
 
-int main(int argc, char* argv[])
-{
+int main(int argc, char* argv[]) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Converts between regular expressions, regular grammars and finite automaton.", ' ', "0.01");
 
 		std::vector<std::string> formalisms {"fa", "re", "rg", "pda" };
diff --git a/aconvert2/src/aconvert.cpp b/aconvert2/src/aconvert.cpp
index a039d94eff..6f99235791 100644
--- a/aconvert2/src/aconvert.cpp
+++ b/aconvert2/src/aconvert.cpp
@@ -137,6 +137,9 @@ void automatonToTikZ ( std::istream & in, std::ostream & out ) {
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Convert binary", ' ', "0.01" );
 
 		TCLAP::SwitchArg automaton_from_string ( "", "automaton_from_string", "Convert automaton from string representation" );
diff --git a/aderivation2/src/aderivation.cpp b/aderivation2/src/aderivation.cpp
index 20198a7ce8..e4b8010f7e 100644
--- a/aderivation2/src/aderivation.cpp
+++ b/aderivation2/src/aderivation.cpp
@@ -17,6 +17,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01");
 		TCLAP::ValueArg<std::string> string(	"s",	"string",	"String to derivate by",	false,	"-",		"file");
 		cmd.add( string );
diff --git a/adeterminize2/src/adeterminize.cpp b/adeterminize2/src/adeterminize.cpp
index 78d9283a49..c76462d486 100644
--- a/adeterminize2/src/adeterminize.cpp
+++ b/adeterminize2/src/adeterminize.cpp
@@ -17,6 +17,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton determinize binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to determinize",		false,	"-",		"file");
diff --git a/aecho2/src/aecho.cpp b/aecho2/src/aecho.cpp
index fb3b14cfed..1c530e8e43 100644
--- a/aecho2/src/aecho.cpp
+++ b/aecho2/src/aecho.cpp
@@ -16,6 +16,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("echo binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to echo",		false,	"-",		"file");
diff --git a/aepsilon2/src/aepsilon.cpp b/aepsilon2/src/aepsilon.cpp
index 7cf5944a10..1df0e3c8cc 100644
--- a/aepsilon2/src/aepsilon.cpp
+++ b/aepsilon2/src/aepsilon.cpp
@@ -20,8 +20,10 @@
 #include "grammar/simplify/EpsilonRemover.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton rename binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton/Grammar where to remove epsilon transitions",		false,	"-",		"file");
diff --git a/agenerate2/src/agenerate.cpp b/agenerate2/src/agenerate.cpp
index d49136fd3b..9cb35ea75c 100644
--- a/agenerate2/src/agenerate.cpp
+++ b/agenerate2/src/agenerate.cpp
@@ -22,6 +22,9 @@
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "String generate from grammar", ' ', "0.01" );
 
 		std::vector < std::string > allowed;
diff --git a/agraphbench2/src/agraphbench.cpp b/agraphbench2/src/agraphbench.cpp
index a7614ba67f..8491b1ca19 100644
--- a/agraphbench2/src/agraphbench.cpp
+++ b/agraphbench2/src/agraphbench.cpp
@@ -13,6 +13,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Graph benchmark binary", ' ', "0.01");
 
 		TCLAP::ValueArg<int> size(	"",	"size",	"Size of graph",		false,	10, "integer");
diff --git a/aintegral2/src/aintegral.cpp b/aintegral2/src/aintegral.cpp
index feb642d292..4e7824901e 100644
--- a/aintegral2/src/aintegral.cpp
+++ b/aintegral2/src/aintegral.cpp
@@ -17,6 +17,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Regexp derivative compute binary", ' ', "0.01");
 		TCLAP::ValueArg<std::string> string(	"s",	"string",	"String to derivate by",	false,	"-",		"file");
 		cmd.add( string );
diff --git a/alangop2/src/alangop.cpp b/alangop2/src/alangop.cpp
index 6cdd3cac7f..0e0a6d94e5 100644
--- a/alangop2/src/alangop.cpp
+++ b/alangop2/src/alangop.cpp
@@ -26,6 +26,9 @@
 
 int main(int argc, char* argv[]) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Stringology algorithm access binary", ' ', "0.01");
 
 		std::vector<std::string> allowed;
diff --git a/alib2common/src/exception/CommonException.cpp b/alib2common/src/exception/CommonException.cpp
index 5c5af56eaf..82bd8dd3d9 100644
--- a/alib2common/src/exception/CommonException.cpp
+++ b/alib2common/src/exception/CommonException.cpp
@@ -10,6 +10,7 @@
 #include "../sax/FromXMLParserHelper.h"
 #include "../object/Object.h"
 #include "../XmlApi.hpp"
+#include "../global/GlobalData.h"
 
 #ifdef DEBUG
 	#include "../debug/simpleStacktrace.h"
@@ -17,28 +18,24 @@
 
 namespace exception {
 
-CommonException::CommonException ( ) {
+CommonException::CommonException ( std::string cause ) : cause(std::move(cause)) {
 	#ifdef DEBUG
 		this->backtrace = std::simpleStacktrace();
 	#else
 		this->backtrace = "";
 	#endif
 
+	for(int i = 0; i < common::GlobalData::argc; i++) {
+		if(i != 0) this->command += " ";
+		this->command += common::GlobalData::argv[i];
+	}
 	this->whatMessage += this->backtrace;
-}
-
-CommonException::CommonException ( std::string cause ) : CommonException { } {
 	this->whatMessage += this->cause;
-
-	this->cause = std::move(cause);
 }
 
-CommonException::CommonException ( std::string cause, std::string backtrace ) {
+CommonException::CommonException ( std::string cause, std::string backtrace, std::string command ) : cause(std::move(cause)), backtrace(std::move(backtrace)), command(std::move(command)) {
 	this->whatMessage += this->backtrace;
 	this->whatMessage += this->cause;
-
-	this->backtrace = std::move(backtrace);
-	this->cause = std::move(cause);
 }
 
 alib::ObjectBase* CommonException::clone() const {
@@ -91,8 +88,15 @@ CommonException CommonException::parse(std::deque<sax::Token>::iterator& input)
 		++input;
 	}
 	sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "backtrace");
+	sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::START_ELEMENT, "command");
+	std::string command = "";
+	if (input->getType() == sax::Token::TokenType::CHARACTER) {
+		command = std::move(*input).moveData();
+		++input;
+	}
+	sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, "command");
 	sax::FromXMLParserHelper::popToken(input, sax::Token::TokenType::END_ELEMENT, CommonException::XML_TAG_NAME);
-	return CommonException(std::move(cause), std::move(backtrace));
+	return CommonException(std::move(cause), std::move(backtrace), std::move(command));
 }
 
 void CommonException::compose(std::deque<sax::Token>& out) const {
@@ -103,6 +107,9 @@ void CommonException::compose(std::deque<sax::Token>& out) const {
 	out.emplace_back("backtrace", sax::Token::TokenType::START_ELEMENT);
 	out.emplace_back(backtrace, sax::Token::TokenType::CHARACTER);
 	out.emplace_back("backtrace", sax::Token::TokenType::END_ELEMENT);
+	out.emplace_back("command", sax::Token::TokenType::START_ELEMENT);
+	out.emplace_back(command, sax::Token::TokenType::CHARACTER);
+	out.emplace_back("command", sax::Token::TokenType::END_ELEMENT);
 	out.emplace_back(CommonException::XML_TAG_NAME, sax::Token::TokenType::END_ELEMENT);
 }
 
diff --git a/alib2common/src/exception/CommonException.h b/alib2common/src/exception/CommonException.h
index f614550c74..0f697f0f72 100644
--- a/alib2common/src/exception/CommonException.h
+++ b/alib2common/src/exception/CommonException.h
@@ -27,13 +27,12 @@ protected:
 	std::string cause;
 	std::string backtrace;
 	std::string whatMessage;
+	std::string command;
 
 public:
-	explicit CommonException ( );
-
 	explicit CommonException ( std::string cause );
 
-	explicit CommonException ( std::string cause, std::string backtrace );
+	explicit CommonException ( std::string cause, std::string backtrace, std::string command );
 
 	virtual alib::ObjectBase * clone ( ) const;
 
diff --git a/alib2common/src/sax/ComposerException.cpp b/alib2common/src/sax/ComposerException.cpp
index e398ec2cc5..3820232044 100644
--- a/alib2common/src/sax/ComposerException.cpp
+++ b/alib2common/src/sax/ComposerException.cpp
@@ -9,10 +9,7 @@
 
 namespace sax {
 
-ComposerException::ComposerException(const Token& expected, const Token& read) :
-		expected(expected), read(read) {
-
-	cause = "Composer Exception: Expected: " + expected.getData() + " Read: " + read.getData();
+ComposerException::ComposerException(const Token& expected, const Token& read) : CommonException("Composer Exception: Expected: " + expected.getData() + " Read: " + read.getData()), expected(expected), read(read) {
 }
 
 } /* namespace sax */
diff --git a/alib2common/src/sax/ParserException.cpp b/alib2common/src/sax/ParserException.cpp
index c92d6c4a0c..3e46284855 100644
--- a/alib2common/src/sax/ParserException.cpp
+++ b/alib2common/src/sax/ParserException.cpp
@@ -9,10 +9,7 @@
 
 namespace sax {
 
-ParserException::ParserException(const Token& expected, const Token& read) :
-		expected(expected), read(read) {
-
-	cause = "Parser Exception: Expected: " + expected.getData() + " Read: " + read.getData();
+ParserException::ParserException(const Token& expected, const Token& read) : CommonException("Parser Exception: Expected: " + expected.getData() + " Read: " + read.getData()), expected(expected), read(read) {
 }
 
 } /* namespace sax */
diff --git a/alib2data/src/alphabet/SymbolException.cpp b/alib2data/src/alphabet/SymbolException.cpp
index 4f838d17ce..fd4c910504 100644
--- a/alib2data/src/alphabet/SymbolException.cpp
+++ b/alib2data/src/alphabet/SymbolException.cpp
@@ -9,9 +9,6 @@
 
 namespace alphabet {
 
-SymbolException::SymbolException() {
-}
-
 SymbolException::SymbolException(const std::string& cause) :
 		CommonException(cause) {
 }
diff --git a/alib2data/src/alphabet/SymbolException.h b/alib2data/src/alphabet/SymbolException.h
index 2c7445b854..c05da7a7b3 100644
--- a/alib2data/src/alphabet/SymbolException.h
+++ b/alib2data/src/alphabet/SymbolException.h
@@ -17,7 +17,6 @@ namespace alphabet {
  */
 class SymbolException: public exception::CommonException {
 public:
-	SymbolException();
 	explicit SymbolException(const std::string& cause);
 };
 
diff --git a/alib2data/src/automaton/AutomatonException.cpp b/alib2data/src/automaton/AutomatonException.cpp
index a533f710da..57193ee179 100644
--- a/alib2data/src/automaton/AutomatonException.cpp
+++ b/alib2data/src/automaton/AutomatonException.cpp
@@ -9,9 +9,6 @@
 
 namespace automaton {
 
-AutomatonException::AutomatonException() {
-}
-
 AutomatonException::AutomatonException(const std::string& cause) :
 		CommonException(cause) {
 }
diff --git a/alib2data/src/automaton/AutomatonException.h b/alib2data/src/automaton/AutomatonException.h
index 3005dfd0a3..1f68a7efb8 100644
--- a/alib2data/src/automaton/AutomatonException.h
+++ b/alib2data/src/automaton/AutomatonException.h
@@ -17,7 +17,6 @@ namespace automaton {
  */
 class AutomatonException: public exception::CommonException {
 public:
-	AutomatonException();
 	explicit AutomatonException(const std::string& cause);
 };
 
diff --git a/alib2data/src/grammar/GrammarException.cpp b/alib2data/src/grammar/GrammarException.cpp
index 83e5c7cc71..f554f459c8 100644
--- a/alib2data/src/grammar/GrammarException.cpp
+++ b/alib2data/src/grammar/GrammarException.cpp
@@ -9,9 +9,6 @@
 
 namespace grammar {
 
-GrammarException::GrammarException() {
-}
-
 GrammarException::GrammarException(const std::string& cause) :
 		CommonException(cause) {
 }
diff --git a/alib2data/src/grammar/GrammarException.h b/alib2data/src/grammar/GrammarException.h
index 847360e22b..e8242fea97 100644
--- a/alib2data/src/grammar/GrammarException.h
+++ b/alib2data/src/grammar/GrammarException.h
@@ -17,7 +17,6 @@ namespace grammar {
  */
 class GrammarException: public exception::CommonException {
 public:
-	GrammarException();
 	explicit GrammarException(const std::string& cause);
 };
 
diff --git a/alib2data/src/tree/TreeException.cpp b/alib2data/src/tree/TreeException.cpp
index e1ebc16f97..12215588cf 100644
--- a/alib2data/src/tree/TreeException.cpp
+++ b/alib2data/src/tree/TreeException.cpp
@@ -9,9 +9,6 @@
 
 namespace tree {
 
-TreeException::TreeException() {
-}
-
 TreeException::TreeException(const std::string& cause) :
 		CommonException(cause) {
 }
diff --git a/alib2data/src/tree/TreeException.h b/alib2data/src/tree/TreeException.h
index 7dd4b74b17..334753b36b 100644
--- a/alib2data/src/tree/TreeException.h
+++ b/alib2data/src/tree/TreeException.h
@@ -17,7 +17,6 @@ namespace tree {
  */
 class TreeException: public exception::CommonException {
 public:
-	TreeException();
 	explicit TreeException(const std::string& cause);
 };
 
diff --git a/alphabetManip2/src/alphabetManip.cpp b/alphabetManip2/src/alphabetManip.cpp
index 8817594865..1a279613db 100644
--- a/alphabetManip2/src/alphabetManip.cpp
+++ b/alphabetManip2/src/alphabetManip.cpp
@@ -55,6 +55,9 @@ void process ( T & data, TCLAP::ValueArg < std::string > & operation, std::deque
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Alphabet manipulation binary", ' ', "0.01" );
 
 		std::vector < std::string > allowed;
diff --git a/ameasure2/src/ameasure.cpp b/ameasure2/src/ameasure.cpp
index 28f5bee981..cae11db582 100644
--- a/ameasure2/src/ameasure.cpp
+++ b/ameasure2/src/ameasure.cpp
@@ -4,20 +4,29 @@
 
 #include "exception/CommonException.h"
 #include "sax/SaxParseInterface.h"
+#include <global/GlobalData.h>
 #include <tclap/CmdLine.h>
 
 #include <measure>
 #include <measurepp>
 
 int main ( int argc, char * * argv ) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Measurement provisioner binary", ' ', "0.01" );
 
 		TCLAP::UnlabeledValueArg < std::string > input ( "input", "provisioning file", false, "-", "file" );
 		cmd.add ( input );
 
-		cmd.parse ( argc, argv );
+		TCLAP::SwitchArg verbose(		"v",	"verbose",	"Be verbose",			false);
+		cmd.add( verbose );
+
+		cmd.parse(argc, argv);
+
+		if(verbose.isSet())
+			common::GlobalData::verbose = true;
 
 		std::deque < sax::Token > tokens;
 
diff --git a/ameasurep2/src/ameasureproc.cpp b/ameasurep2/src/ameasureproc.cpp
index ba60963a3f..99e9f645cc 100644
--- a/ameasurep2/src/ameasureproc.cpp
+++ b/ameasurep2/src/ameasureproc.cpp
@@ -4,14 +4,17 @@
 
 #include "exception/CommonException.h"
 #include "sax/SaxParseInterface.h"
+#include <global/GlobalData.h>
 #include <tclap/CmdLine.h>
 
 #include <measure>
 #include <measurepp>
 
 int main ( int argc, char * * argv ) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Measurement processor binary", ' ', "0.01" );
 
 		std::vector < std::string > allowedOutput;
@@ -48,7 +51,13 @@ int main ( int argc, char * * argv ) {
 		TCLAP::UnlabeledValueArg < std::string > input ( "input", "provisioning results file", false, "-", "file" );
 		cmd.add ( input );
 
-		cmd.parse ( argc, argv );
+		TCLAP::SwitchArg verbose(		"v",	"verbose",	"Be verbose",			false);
+		cmd.add( verbose );
+
+		cmd.parse(argc, argv);
+
+		if(verbose.isSet())
+			common::GlobalData::verbose = true;
 
 		std::deque < sax::Token > tokens;
 
diff --git a/aminimize2/src/aminimize.cpp b/aminimize2/src/aminimize.cpp
index 004a416941..8a4739a3c9 100644
--- a/aminimize2/src/aminimize.cpp
+++ b/aminimize2/src/aminimize.cpp
@@ -17,8 +17,10 @@
 #include "automaton/simplify/MinimizeBrzozowski.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton minimize binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to minimize",	false,	"-",		"file");
diff --git a/anormalize2/src/anormalize.cpp b/anormalize2/src/anormalize.cpp
index 957698ebfc..73284372b7 100644
--- a/anormalize2/src/anormalize.cpp
+++ b/anormalize2/src/anormalize.cpp
@@ -22,8 +22,10 @@
 #include "grammar/parsing/DeterministicLL1Grammar.h"
 
 int main ( int argc, char * * argv ) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Automaton normalize binary", ' ', "0.01" );
 
 		TCLAP::ValueArg < std::string > input ( "i", "input", "Input to normalize", false, "-", "file" );
diff --git a/arand2/src/arand.cpp b/arand2/src/arand.cpp
index 26c435c11e..c12fd9d6b1 100644
--- a/arand2/src/arand.cpp
+++ b/arand2/src/arand.cpp
@@ -21,6 +21,9 @@
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Random generator binary", ' ', "0.01" );
 
 		std::vector < std::string > allowed;
diff --git a/araw2/src/araw.cpp b/araw2/src/araw.cpp
index f81b5e4f6d..f0bbe20094 100644
--- a/araw2/src/araw.cpp
+++ b/araw2/src/araw.cpp
@@ -23,6 +23,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("raw reading binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to read",		false,	"-",		"file");
diff --git a/arename2/src/arename.cpp b/arename2/src/arename.cpp
index c71839e22c..226e7c83bb 100644
--- a/arename2/src/arename.cpp
+++ b/arename2/src/arename.cpp
@@ -15,8 +15,10 @@
 #include "automaton/simplify/Rename.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton rename binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to rename",		false,	"-",		"file");
diff --git a/areverse2/src/areverse.cpp b/areverse2/src/areverse.cpp
index 8e7e79e133..2884225fa4 100644
--- a/areverse2/src/areverse.cpp
+++ b/areverse2/src/areverse.cpp
@@ -15,8 +15,10 @@
 #include "automaton/transform/Reverse.h"
 
 int main(int argc, char** argv) {
-
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton reverse binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Automaton to reverse",		false,	"-",		"file");
diff --git a/arun2/src/arun.cpp b/arun2/src/arun.cpp
index 255be348a1..900f83169c 100644
--- a/arun2/src/arun.cpp
+++ b/arun2/src/arun.cpp
@@ -27,6 +27,9 @@
 
 int main(int argc, char* argv[]) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Automaton run binary", ' ', "0.01");
 
 		std::vector<std::string> allowed;
diff --git a/astat2/src/astat.cpp b/astat2/src/astat.cpp
index 115c22f5ca..d3caba8449 100644
--- a/astat2/src/astat.cpp
+++ b/astat2/src/astat.cpp
@@ -36,6 +36,9 @@ PrintingOptions translatePrintingOptions ( std::string value ) {
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Prints usefull information about automata, grammars, regexps, ...", ' ', "0.01" );
 
 		// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
diff --git a/astringology2/src/astringology.cpp b/astringology2/src/astringology.cpp
index 3c7d355b0a..5b69fb38de 100644
--- a/astringology2/src/astringology.cpp
+++ b/astringology2/src/astringology.cpp
@@ -38,6 +38,9 @@
 
 int main ( int argc, char * argv[] ) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd ( "Stringology algorithm access binary", ' ', "0.01" );
 
 		std::vector < std::string > allowed;
diff --git a/atrim2/src/atrim.cpp b/atrim2/src/atrim.cpp
index 24b04e0599..01b0421849 100644
--- a/atrim2/src/atrim.cpp
+++ b/atrim2/src/atrim.cpp
@@ -60,6 +60,9 @@ regexp::RegExp optimizeRegExp(const regexp::RegExp& r) {
 
 int main(int argc, char* argv[]) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Removes unreachable and useless states from FSM, productive and unreachable nonterminals from CFG. Simplifies representation of RE", ' ', "0.01");
 
 		TCLAP::SwitchArg useless(		"u",	"useless",	"Removes useless states (or symbols). (works with FSM or CFG)"		);
diff --git a/tniceprint/src/tniceprint.cpp b/tniceprint/src/tniceprint.cpp
index 09a7951bd2..8c8e26e0c1 100644
--- a/tniceprint/src/tniceprint.cpp
+++ b/tniceprint/src/tniceprint.cpp
@@ -18,6 +18,9 @@
 
 int main(int argc, char** argv) {
 	try {
+		common::GlobalData::argc = argc;
+		common::GlobalData::argv = argv;
+
 		TCLAP::CmdLine cmd("Tree nice print binary", ' ', "0.01");
 
 		TCLAP::ValueArg<std::string> input(	"i",	"input",	"Input to nice print",		false,	"-",		"file");
-- 
GitLab