summaryrefslogtreecommitdiff
path: root/tools/hscript-validate/validator.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:52 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:52 -0500
commitbaaf248ae130ebf9aa9d35c6d66f7e2180d5d061 (patch)
treeb810aad16c1cc7f8617abd40dfe5b6c9cb019e64 /tools/hscript-validate/validator.cc
parentd31982310965cb23c8abb51320742420a3d168b5 (diff)
downloadhorizon-baaf248ae130ebf9aa9d35c6d66f7e2180d5d061.tar.gz
horizon-baaf248ae130ebf9aa9d35c6d66f7e2180d5d061.tar.bz2
horizon-baaf248ae130ebf9aa9d35c6d66f7e2180d5d061.tar.xz
horizon-baaf248ae130ebf9aa9d35c6d66f7e2180d5d061.zip
validator: Use clipp, add -k/--keep-going flag
Diffstat (limited to 'tools/hscript-validate/validator.cc')
-rw-r--r--tools/hscript-validate/validator.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/tools/hscript-validate/validator.cc b/tools/hscript-validate/validator.cc
index e9e1979..5ebb9d4 100644
--- a/tools/hscript-validate/validator.cc
+++ b/tools/hscript-validate/validator.cc
@@ -11,14 +11,23 @@
#include "hscript/script.hh"
#include "util/output.hh"
+#include "3rdparty/clipp.h"
int main(int argc, char *argv[]) {
const Horizon::Script *my_script;
Horizon::ScriptOptions opts;
+ int result_code = EXIT_SUCCESS;
+ std::string installfile;
- if(argc < 2) {
- output_error("hscript-validate", "No installfile specified", "", true);
- std::cerr << "Run `" << argv[0] << " --help` for usage information." << std::endl;
+ auto cli = (
+ clipp::value("installfile", installfile),
+ clipp::option("-k", "--keep-going").doc("Continue parsing after errors")(
+ [&opts] { opts.set(Horizon::ScriptOptionFlags::KeepGoing); }
+ )
+ );
+ if(!clipp::parse(argc, argv, cli)) {
+ std::cout << "usage:" << std::endl;
+ std::cout << clipp::usage_lines(cli, "hscript-validate") << std::endl;
return EXIT_FAILURE;
}
@@ -28,12 +37,19 @@ int main(int argc, char *argv[]) {
opts.set(Horizon::ScriptOptionFlags::Pretty);
- my_script = Horizon::Script::load(argv[1], opts);
+ my_script = Horizon::Script::load(installfile, opts);
if(my_script == nullptr) {
std::cout << "Could not load the specified script." << std::endl;
return EXIT_FAILURE;
}
- delete my_script;
- return EXIT_SUCCESS;
+ if(!my_script->validate()) {
+ output_error("installfile", "Script failed validation step. Stop.", "", true);
+ result_code = EXIT_FAILURE;
+ } else {
+ output_info("installfile", "Script passed validation.", "", true);
+ }
+
+ delete my_script;
+ return result_code;
}