5 #include <boost/optional.hpp>
7 #include "info/globalcode/parameterLister/terminalCodes/TerminalCodes.h"
8 #include "info/globalcode/parameterLister/OutputModule.h"
9 #include "info/globalcode/parameterLister/TerminalOutputModule.h"
12 using namespace info::globalcode::parameterLister;
15 namespace globalcode {
16 namespace parameterLister {
18 boost::optional<string> getenv(const string name) {
19 const char * value = ::getenv(name.c_str());
21 return boost::optional<string>();
23 return boost::optional<string>(value);
32 int main(int argc, char* argv[]) {
33 terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN);
34 terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT);
36 cout << "INFO: " << fgGreen << "Parameter lister" << fgReset << " is starting" << endl;
38 string command = argv[0];
41 for (int i = 1; i < argc; i++) {
42 args.push_back(argv[i]);
45 for_each(args.begin(), args.end(), [command, fgGreen, fgReset](string s) {
46 cout << fgGreen << command << fgReset << ": " << s << endl;
50 for (int i = 0; i < args.size(); i++) {
52 cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl;
56 string envName = args[0];
57 boost::optional<string> outputModule = getenv(envName);
59 if (outputModule.is_initialized()) {
60 cout << "ENV: " << envName << " = " << outputModule.get() << endl;
62 cout << "ENV: " << envName << " is missing" << endl;
68 TerminalOutputModule tom;