c++/parameter-lister/CLI.cpp
changeset 11 870b868b6b57
parent 10 145b45ef7751
child 15 09adb33465e4
     1.1 --- a/c++/parameter-lister/CLI.cpp	Sun May 03 23:41:43 2015 +0200
     1.2 +++ b/c++/parameter-lister/CLI.cpp	Mon May 04 00:12:33 2015 +0200
     1.3 @@ -25,10 +25,6 @@
     1.4  	}
     1.5  }
     1.6  
     1.7 -void process(shared_ptr<OutputModule> om) {
     1.8 -	om->process(cout);
     1.9 -}
    1.10 -
    1.11  }
    1.12  }
    1.13  }
    1.14 @@ -46,16 +42,7 @@
    1.15  		args.push_back(argv[i]);
    1.16  	}
    1.17  
    1.18 -	for_each(args.begin(), args.end(), [command, fgGreen, fgReset](string s) {
    1.19 -		cout << fgGreen << command << fgReset << ": " << s << endl;
    1.20 -	});
    1.21 -
    1.22 -
    1.23 -	for (int i = 0; i < args.size(); i++) {
    1.24 -		string s = args[i];
    1.25 -		cout << i + 1 << ":" << s.length() << " = \"" << s << "\"" << endl;
    1.26 -	}
    1.27 -
    1.28 +	/** Load environment variable */
    1.29  	{
    1.30  		string envName = args[0];
    1.31  		boost::optional<string> outputModule = getenv(envName);
    1.32 @@ -67,14 +54,15 @@
    1.33  		}
    1.34  	}
    1.35  
    1.36 +	/** Do formatting */
    1.37  	{
    1.38  		shared_ptr<OutputModule> om(new OutputModule());
    1.39  		shared_ptr<TerminalOutputModule> tom(new TerminalOutputModule());
    1.40  		shared_ptr<OutputModule> o(new TerminalOutputModule());
    1.41  
    1.42 -		process(om);
    1.43 -		process(tom);
    1.44 -		process(o);
    1.45 +		om->process(cout, command, args);
    1.46 +		tom->process(cout, command, args);
    1.47 +		o->process(cout, command, args);
    1.48  	}
    1.49  
    1.50  	return 0;