diff options
| author | Grégoire Duchêne <gduchene@fastmail.net> | 2011-02-19 19:59:06 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@fastmail.net> | 2011-02-19 19:59:06 +0100 |
| commit | 7eb113cce7dcfd60bc54f30e65cff899550c8428 (patch) | |
| tree | 1f386e787497e9b24f972831a75e92e4744c9af2 /src | |
| parent | 7fa9597789edf8babd19e46d622c5d23d948ca2f (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 18 |
1 files 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<string>(), "set the input file") + ("output,o", po::value<string>(), "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<string>().c_str()); + + if (ofile.fail()) { + cerr << "mppdown: error while opening the output file" << endl; + return 1; + } + + ofile << output; + ofile.close(); + } + return 0; } |
