diff options
author | 2011-04-21 22:52:31 +0800 | |
---|---|---|
committer | 2011-04-26 18:50:39 +0800 | |
commit | 8a521c26265103005783a625ed097968f84ebc98 (patch) | |
tree | 31d1e3ad347621ef5650c63b4e56d70e1ac90b35 /utils | |
parent | Core: support DEFINED_PHASES for metadata generation (diff) | |
download | libbash-8a521c26265103005783a625ed097968f84ebc98.tar.gz libbash-8a521c26265103005783a625ed097968f84ebc98.tar.bz2 libbash-8a521c26265103005783a625ed097968f84ebc98.zip |
Utility: improve the output format of metadata_generator
The metadata_generator now generates the same format as what
Portage does.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/metadata_generator.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/metadata_generator.cpp b/utils/metadata_generator.cpp index 57facb1..859839c 100644 --- a/utils/metadata_generator.cpp +++ b/utils/metadata_generator.cpp @@ -27,6 +27,9 @@ #include <vector> #include <boost/spirit/include/karma.hpp> +#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string/split.hpp> +#include <boost/algorithm/string/trim.hpp> #include "libbash.h" @@ -55,6 +58,8 @@ static const std::unordered_map<std::string, std::string> phases = { int main(int argc, char** argv) { + using namespace boost::spirit::karma; + if(argc != 2) { std::cerr<<"Please provide your script as an argument"<<std::endl; @@ -69,9 +74,19 @@ int main(int argc, char** argv) { auto iter_value = variables.find(*iter_name); if(iter_value != variables.end()) - std::cout << iter_value->second[0] << std::endl; + { + std::vector<std::string> formatted; + boost::trim_if(iter_value->second[0], boost::is_any_of(" \t\n")); + boost::split(formatted, + iter_value->second[0], + boost::is_any_of(" \t\n"), + boost::token_compress_on); + std::cout << format(string % ' ', formatted) << std::endl; + } else + { std::cout << std::endl; + } } // Print defined phases |