diff --git a/CMakeLists.txt b/CMakeLists.txt index f2feb82..0442475 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(META_GUI_OPTIONAL true) set(META_JS_SRC_DIR renamingutility) set(META_VERSION_MAJOR 2) set(META_VERSION_MINOR 3) -set(META_VERSION_PATCH 2) +set(META_VERSION_PATCH 3) set(META_NO_TIDY ON) # add project files diff --git a/application/main.cpp b/application/main.cpp index c87467b..c8af213 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -220,10 +220,11 @@ int main(int argc, char *argv[]) extractFieldArg.setDenotesOperation(true); extractFieldArg.setCallback(std::bind(Cli::extractField, std::cref(fieldArg), std::cref(attachmentArg), std::cref(fileArg), std::cref(outputFileArg), std::cref(verboseArg))); // export to JSON + ConfigValueArgument prettyArg("pretty", '\0', "prints with indentation and spacing"); Argument exportArg("export", 'j', "exports the tag information for the specified files to JSON"); - exportArg.setSubArguments({&filesArg}); + exportArg.setSubArguments({&filesArg, &prettyArg}); exportArg.setDenotesOperation(true); - exportArg.setCallback(std::bind(Cli::exportToJson, _1, std::cref(filesArg))); + exportArg.setCallback(std::bind(Cli::exportToJson, _1, std::cref(filesArg), std::cref(prettyArg))); // file info Argument validateArg("validate", 'c', "validates the file integrity as accurately as possible; the structure of the file will be parsed completely"); validateArg.setCombinable(true); diff --git a/cli/mainfeatures.cpp b/cli/mainfeatures.cpp index 7f6fc72..621441d 100644 --- a/cli/mainfeatures.cpp +++ b/cli/mainfeatures.cpp @@ -39,6 +39,7 @@ #ifdef TAGEDITOR_JSON_EXPORT #include #include +#include #endif #include @@ -855,7 +856,7 @@ void extractField(const Argument &fieldArg, const Argument &attachmentArg, const } } -void exportToJson(const ArgumentOccurrence &, const Argument &filesArg) +void exportToJson(const ArgumentOccurrence &, const Argument &filesArg, const Argument &prettyArg) { CMD_UTILS_START_CONSOLE; @@ -891,8 +892,13 @@ void exportToJson(const ArgumentOccurrence &, const Argument &filesArg) // print the gathered data as JSON document ReflectiveRapidJSON::JsonReflector::push(jsonData, document, document.GetAllocator()); RAPIDJSON_NAMESPACE::OStreamWrapper osw(cout); - RAPIDJSON_NAMESPACE::Writer writer(osw); - document.Accept(writer); + if (prettyArg.isPresent()) { + RAPIDJSON_NAMESPACE::PrettyWriter writer(osw); + document.Accept(writer); + } else { + RAPIDJSON_NAMESPACE::Writer writer(osw); + document.Accept(writer); + } cout << endl; #else diff --git a/cli/mainfeatures.h b/cli/mainfeatures.h index fbcb77e..72f0ef2 100644 --- a/cli/mainfeatures.h +++ b/cli/mainfeatures.h @@ -53,7 +53,7 @@ void generateFileInfo(const ApplicationUtilities::ArgumentOccurrence &, const Ap void displayTagInfo(const ApplicationUtilities::Argument &fieldsArg, const ApplicationUtilities::Argument &filesArg, const ApplicationUtilities::Argument &verboseArg); void setTagInfo(const Cli::SetTagInfoArgs &args); void extractField(const ApplicationUtilities::Argument &fieldArg, const ApplicationUtilities::Argument &attachmentArg, const ApplicationUtilities::Argument &inputFilesArg, const ApplicationUtilities::Argument &outputFileArg, const ApplicationUtilities::Argument &verboseArg); -void exportToJson(const ApplicationUtilities::ArgumentOccurrence &, const ApplicationUtilities::Argument &filesArg); +void exportToJson(const ApplicationUtilities::ArgumentOccurrence &, const ApplicationUtilities::Argument &filesArg, const ApplicationUtilities::Argument &prettyArg); }