From 662fa9c7a299c70bf5e7ee4266fb3db258b7e979 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Sat, 1 Jul 2017 21:18:01 +0200 Subject: [PATCH 1/3] Added --output CLI option --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index ff05e59..a2825ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,6 +23,7 @@ #include #include #include "targetShapeSet.h" +#include using std::exception; using std::string; @@ -35,8 +36,10 @@ using std::make_shared; using std::map; using std::chrono::duration; using std::chrono::duration_cast; +using std::ofstream; using boost::filesystem::path; using boost::adaptors::transformed; +using boost::optional; namespace tclap = TCLAP; @@ -103,6 +106,7 @@ int main(int argc, char *argv[]) { tclap::CmdLine cmd(appName, argumentValueSeparator, appVersion); cmd.setExceptionHandling(false); cmd.setOutput(new NiceCmdLineOutput()); + tclap::ValueArg outputFileName("o", "output", "The output file path.", false, string(), "string", cmd); auto logLevels = vector(logging::LevelConverter::get().getValues()); tclap::ValuesConstraint logLevelConstraint(logLevels); tclap::ValueArg logLevel("", "logLevel", "The minimum log level to log", false, logging::Level::Debug, &logLevelConstraint, cmd); @@ -163,7 +167,12 @@ int main(int argc, char *argv[]) { // Export animation unique_ptr exporter = createExporter(exportFormat.getValue()); - exporter->exportAnimation(inputFilePath, animation, targetShapeSet, std::cout); + optional outputFile; + if (outputFileName.isSet()) { + outputFile = boost::in_place(outputFileName.getValue()); + outputFile->exceptions(std::ifstream::failbit | std::ifstream::badbit); + } + exporter->exportAnimation(inputFilePath, animation, targetShapeSet, outputFile ? *outputFile : std::cout); logging::info("Exiting application normally."); } catch (...) { From 93327ff646c034fb081bbc8b33998d92f4ee50c7 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Sat, 1 Jul 2017 21:27:10 +0200 Subject: [PATCH 2/3] Documented --output option --- README.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index 51a072e..90c2954 100644 --- a/README.adoc +++ b/README.adoc @@ -77,8 +77,8 @@ This shape is also used as an in-between when animating from {C} or {D} to {F}. Rhubarb Lip-Sync is a command-line tool that is currently available for Windows and OS X. * Download the https://github.com/DanielSWolf/rhubarb-lip-sync/releases[latest release] and unzip the file anywhere on your computer. -* Call `rhubarb`, passing it a WAVE file as argument, and redirecting the output to a file. In its simplest form, this might look like this: `rhubarb my-recording.wav > output.txt`. There are additional <> you can specify in order to get better results. -* Rhubarb Lip-Sync will analyze the sound file and print the result to `stdout`. If you've redirected `stdout` to a file like above, you will now have an XML file containing the lip-sync data. If an error occurs, Rhubarb Lip-Sync will print an error message to `stderr` and exit with a non-zero exit code. +* Call `rhubarb`, passing it a WAVE file as argument and telling it where to create the output file. In its simplest form, this might look like this: `rhubarb -o output.txt my-recording.wav`. There are additional <> you can specify in order to get better results. +* Rhubarb Lip-Sync will analyze the sound file, animate it, and create an output file containing the animation. If an error occurs, Rhubarb Lip-Sync will instead print an error message to `stderr` and exit with a non-zero exit code. [[options]] === Command-line options === @@ -125,6 +125,9 @@ _Default value: as many threads as your CPU has cores_ _Default value: ``debug``_ +| `-o`, `--output` __ +| The name of the output file to create. If the file already exists, it will be overwritten. If you don't specify an output file, the result will be written to `stdout`. + | `--version` | Displays version information and exits. From 9bbdf4ffdf38efc786cf6c63aef077fae19f419f Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Sat, 1 Jul 2017 21:54:37 +0200 Subject: [PATCH 3/3] Updated VERSION.md --- VERSION.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VERSION.md b/VERSION.md index 5d41259..69fd753 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,5 +1,9 @@ # Version history +## Unreleased + +* Added --output command-line option + ## Version 1.5.0 * Improved animation rules for ER and AW sounds