Commit 38606790 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Add a show info (host and time) and do not quit if show info or show compile is call

parent a1123352
......@@ -24,6 +24,8 @@
#include <iostream>
#include <vector>
#include <chrono>
#include <unistd.h>
/**
* This file contains some useful classes/functions to manage the parameters,
......@@ -50,6 +52,11 @@ static const FParameterNames Compile = {
"To have the list of flags and lib linked to scalfmm."
};
static const FParameterNames DateHost = {
{"-show-info", "--show-host", "--datehost"} ,
"To have to print the current host and the execution date."
};
static const FParameterNames NbParticles = {
{"-nb", "--number-of-particles", "-N"} ,
"The number of particles if they are generated by the executable."
......@@ -185,8 +192,18 @@ inline void PrintUsedOptions(const std::vector<FParameterNames>& options){
inline void PrintFlags(){
std::cout << "This executable has been compiled with:\n";
std::cout << "Flags = " << SCALFMMCompileFlags << "\n";
std::cout << "Libs = " << SCALFMMCompileLibs << "\n";
std::cout << "× Flags = " << SCALFMMCompileFlags << "\n";
std::cout << "× Libs = " << SCALFMMCompileLibs << "\n";
std::cout.flush();
}
inline void PrintDateHost(){
std::cout << "This execution is on:\n";
std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::cout << "× Date = " << std::ctime(&now) << "\n";
char hostname[1024];
gethostname(hostname, 1024);
std::cout << "× Host = " << hostname << "\n";
std::cout.flush();
}
......@@ -198,10 +215,12 @@ inline void PrintFlags(){
#define FHelpAndExit(argc, argv, ...) \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Compile.options)) {\
FParameterDefinitions::PrintFlags();\
return 0;\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::DateHost.options)) {\
FParameterDefinitions::PrintDateHost();\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Help.options)) {\
const std::vector<FParameterNames> optionsvec = {__VA_ARGS__};\
const std::vector<FParameterNames> optionsvec = {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, __VA_ARGS__};\
FParameterDefinitions::PrintUsedOptions(optionsvec);\
return 0;\
} \
......@@ -214,11 +233,13 @@ inline void PrintFlags(){
#define FHelpDescribeAndExit(argc, argv, description, ...) \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Compile.options)) {\
FParameterDefinitions::PrintFlags();\
return 0;\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::DateHost.options)) {\
FParameterDefinitions::PrintDateHost();\
} \
if(FParameters::existParameter(argc, argv, FParameterDefinitions::Help.options)) {\
std::cout << argv[0] << " : " << description << "\n"; \
const std::vector<FParameterNames> optionsvec = {__VA_ARGS__};\
const std::vector<FParameterNames> optionsvec = {FParameterDefinitions::Compile, FParameterDefinitions::DateHost, __VA_ARGS__};\
FParameterDefinitions::PrintUsedOptions(optionsvec);\
return 0;\
} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment