franta-hg@0: #include franta-hg@1: #include franta-hg@3: #include franta-hg@3: #include franta-hg@5: #include franta-hg@10: #include franta-hg@3: franta-hg@5: #include "info/globalcode/parameterLister/terminalCodes/TerminalCodes.h" franta-hg@7: #include "info/globalcode/parameterLister/OutputModule.h" franta-hg@7: #include "info/globalcode/parameterLister/TerminalOutputModule.h" franta-hg@0: franta-hg@0: using namespace std; franta-hg@3: using namespace info::globalcode::parameterLister; franta-hg@0: franta-hg@5: namespace info { franta-hg@5: namespace globalcode { franta-hg@5: namespace parameterLister { franta-hg@5: franta-hg@5: boost::optional getenv(const string name) { franta-hg@5: const char * value = ::getenv(name.c_str()); franta-hg@5: if (value == 0) { franta-hg@5: return boost::optional(); franta-hg@5: } else { franta-hg@5: return boost::optional(value); franta-hg@5: } franta-hg@5: } franta-hg@5: franta-hg@10: void process(shared_ptr om) { franta-hg@10: om->process(cout); franta-hg@10: } franta-hg@5: franta-hg@5: } franta-hg@5: } franta-hg@5: } franta-hg@5: franta-hg@3: int main(int argc, char* argv[]) { franta-hg@1: terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN); franta-hg@1: terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT); franta-hg@4: franta-hg@3: cout << "INFO: " << fgGreen << "Parameter lister" << fgReset << " is starting" << endl; franta-hg@1: franta-hg@3: string command = argv[0]; franta-hg@3: vector args; franta-hg@3: franta-hg@3: for (int i = 1; i < argc; i++) { franta-hg@3: args.push_back(argv[i]); franta-hg@3: } franta-hg@3: franta-hg@3: for_each(args.begin(), args.end(), [command, fgGreen, fgReset](string s) { franta-hg@3: cout << fgGreen << command << fgReset << ": " << s << endl; franta-hg@3: }); franta-hg@3: franta-hg@3: franta-hg@4: for (int i = 0; i < args.size(); i++) { franta-hg@4: string s = args[i]; franta-hg@4: cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl; franta-hg@4: } franta-hg@4: franta-hg@5: { franta-hg@5: string envName = args[0]; franta-hg@5: boost::optional outputModule = getenv(envName); franta-hg@4: franta-hg@5: if (outputModule.is_initialized()) { franta-hg@9: cout << "ENV: " << envName << " = " << outputModule.get() << endl; franta-hg@5: } else { franta-hg@9: cout << "ENV: " << envName << " is missing" << endl; franta-hg@5: } franta-hg@5: } franta-hg@10: franta-hg@7: { franta-hg@10: shared_ptr om(new OutputModule()); franta-hg@10: shared_ptr tom(new TerminalOutputModule()); franta-hg@10: shared_ptr o(new TerminalOutputModule()); franta-hg@10: franta-hg@10: process(om); franta-hg@10: process(tom); franta-hg@10: process(o); franta-hg@7: } franta-hg@3: franta-hg@0: return 0; franta-hg@10: }