Add --pretty flag to JSON export
This commit is contained in:
parent
a00ec48405
commit
5254e6cdf9
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#ifdef TAGEDITOR_JSON_EXPORT
|
||||
#include <rapidjson/ostreamwrapper.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <rapidjson/prettywriter.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@ -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<RAPIDJSON_NAMESPACE::OStreamWrapper> writer(osw);
|
||||
document.Accept(writer);
|
||||
if (prettyArg.isPresent()) {
|
||||
RAPIDJSON_NAMESPACE::PrettyWriter<RAPIDJSON_NAMESPACE::OStreamWrapper> writer(osw);
|
||||
document.Accept(writer);
|
||||
} else {
|
||||
RAPIDJSON_NAMESPACE::Writer<RAPIDJSON_NAMESPACE::OStreamWrapper> writer(osw);
|
||||
document.Accept(writer);
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
#else
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue