From 7eb113cce7dcfd60bc54f30e65cff899550c8428 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sat, 19 Feb 2011 19:59:06 +0100 Subject: New "output" option added. This option will allow users to specify a file which will be used by mppdown to write the parsed result. If this option is not set, mppdown will still write the parsed result to standard output. --- src/main.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 08d520a..3c74993 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,8 @@ int main(int argc, char** argv) { general.add_options() ("help,h", "produce this message") - ("input,i", "set the input file"); + ("input,i", po::value(), "set the input file") + ("output,o", po::value(), "set the output file"); pgeneral.add("input", -1); @@ -89,6 +90,19 @@ int main(int argc, char** argv) { return 1; } - wcout << output << flush; + if (!variables.count("output")) + wcout << output << flush; + else { + wofstream ofile(variables["output"].as().c_str()); + + if (ofile.fail()) { + cerr << "mppdown: error while opening the output file" << endl; + return 1; + } + + ofile << output; + ofile.close(); + } + return 0; } -- cgit v1.2.3-70-g09d2