From 5eaf7c676d5d5a76ac10d2569aaba7c22ec3e6d3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Jun 2019 12:10:16 +0200 Subject: Improve dgvalidator usage and add man page for it. --- drumgizmo/dgvalidator.cc | 41 ++++++++++++++++++++++++++++++++++++++++- man/dgvalidator.1 | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 man/dgvalidator.1 diff --git a/drumgizmo/dgvalidator.cc b/drumgizmo/dgvalidator.cc index d0cef8d..d7557aa 100644 --- a/drumgizmo/dgvalidator.cc +++ b/drumgizmo/dgvalidator.cc @@ -34,8 +34,32 @@ #include #include +void printUsage(const char* prog, bool full = true) +{ + printf("Usage: %s |-h|--help\n", prog); + if(!full) + { + return; + } + printf("Validates the xml and semantics of the drumkit file and prints " + "any found errors to the console.\n"); + printf("Returns 0 on success or 1 if errors were found.\n"); +} + int main(int argc, char* argv[]) { + if(argc != 2) + { + printUsage(argv[0], false); + return 1; + } + + if(std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help") + { + printUsage(argv[0]); + return 1; + } + std::string edited_filename = argv[1]; DrumkitDOM drumkitdom; std::vector instrumentdoms; @@ -86,5 +110,20 @@ int main(int argc, char* argv[]) return 1; } - return 0; + // Verify all referred audiofiles + for(const auto& instrument: kit.instruments) + { + for(auto& audiofile: instrument->audiofiles) + { + audiofile->load(1); + if(!audiofile->isLoaded()) + { + WARN(drumkitloader, "Instrument file load error: '%s'", + audiofile->filename.data()); + parseerror = true; + } + } + } + + return parseerror ? 1 : 0; } diff --git a/man/dgvalidator.1 b/man/dgvalidator.1 new file mode 100644 index 0000000..dde1358 --- /dev/null +++ b/man/dgvalidator.1 @@ -0,0 +1,36 @@ +.TH "DGVALIDATOR" "1" "29 June 2019" "dgvalidator" "" + +.SH NAME +dgvalidator \- drumgizmo drumkit validator + +.SH SYNOPSIS +\fBdgvalidator\fR |-h|--help + +.SH "DESCRIPTION" +.PP +\fBDgvalidator\fR is a simple validator tool for drumgizmo drumkit files. +.PP +Dgvalidator will try to load the drumkit pointed to by drumkitfile and +validate it. It validates both the xml in the drumkit and all instrument files +referred in it as well as the the semantics of the contents - +including checking for the existance and validity of all audiofiles +referred by the instruments. + +.SH "OPTIONS" +.PD 0 +.RE +\fB-h, --help\fR +.RS 7 +Print command line help and exit. + +.RE +\fBdrumkitfile\fR +.RS 7 +The drumkitfile to verify. + +.RE +.SH "BUGS" +Report bugs to http://www.drumgizmo.org/wiki/doku.php?id=bugs. + +.SH "ADDITIONAL INFORMATION" +For further information, visit the website http://www.drumgizmo.org. -- cgit v1.2.3