1.1 --- a/c++/parameter-lister/CLI.cpp Sun May 03 17:05:51 2015 +0200
1.2 +++ b/c++/parameter-lister/CLI.cpp Sun May 03 18:08:40 2015 +0200
1.3 @@ -2,12 +2,31 @@
1.4 #include <iostream>
1.5 #include <vector>
1.6 #include <algorithm>
1.7 +#include <boost/optional.hpp>
1.8
1.9 -#include "info/globalcode/terminalCodes/TerminalCodes.h"
1.10 +#include "info/globalcode/parameterLister/terminalCodes/TerminalCodes.h"
1.11
1.12 using namespace std;
1.13 using namespace info::globalcode::parameterLister;
1.14
1.15 +namespace info {
1.16 +namespace globalcode {
1.17 +namespace parameterLister {
1.18 +
1.19 +boost::optional<string> getenv(const string name) {
1.20 + const char * value = ::getenv(name.c_str());
1.21 + if (value == 0) {
1.22 + return boost::optional<string>();
1.23 + } else {
1.24 + return boost::optional<string>(value);
1.25 + }
1.26 +}
1.27 +
1.28 +
1.29 +}
1.30 +}
1.31 +}
1.32 +
1.33 int main(int argc, char* argv[]) {
1.34 terminalCodes::Modifier fgGreen(terminalCodes::FG_GREEN);
1.35 terminalCodes::Modifier fgReset(terminalCodes::FG_DEFAULT);
1.36 @@ -31,24 +50,17 @@
1.37 cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl;
1.38 }
1.39
1.40 + {
1.41 + string envName = args[0];
1.42 + boost::optional<string> outputModule = getenv(envName);
1.43
1.44 + if (outputModule.is_initialized()) {
1.45 + cout << "ENV: " << envName << " = " << outputModule.get();
1.46 + } else {
1.47 + cout << "ENV: " << envName << " is missing";
1.48 + }
1.49 + }
1.50
1.51
1.52 return 0;
1.53 -}
1.54 -
1.55 -
1.56 -
1.57 -namespace info {
1.58 -namespace globalcode {
1.59 -namespace parameterLister {
1.60 -
1.61 -
1.62 -
1.63 -
1.64 -
1.65 -}
1.66 -}
1.67 -}
1.68 -
1.69 -
1.70 +}
1.71 \ No newline at end of file