summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:57:44 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:57:44 -0500
commitee19bcceefbd1c4c604d1afe832e0b6f669d5eae (patch)
tree896cfe715aea1e9786896e74d02b5bffab21ba69 /tools
parent831f22fb241e6bbf6e03a61f76932a22a63e4564 (diff)
downloadhorizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.gz
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.bz2
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.xz
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.zip
Make +pretty+ a global var instead of passed everywhere
Diffstat (limited to 'tools')
-rw-r--r--tools/hscript-validate/validator.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/hscript-validate/validator.cc b/tools/hscript-validate/validator.cc
index cdcb43d..cfaf38d 100644
--- a/tools/hscript-validate/validator.cc
+++ b/tools/hscript-validate/validator.cc
@@ -14,6 +14,8 @@
#include "util/output.hh"
#include "3rdparty/clipp.h"
+bool pretty = false;
+
int main(int argc, char *argv[]) {
const Horizon::Script *my_script;
Horizon::ScriptOptions opts;
@@ -23,7 +25,7 @@ int main(int argc, char *argv[]) {
/* Default to pretty if we are using a TTY, unless -n specified. */
if(isatty(1) && isatty(2)) {
- opts.set(Horizon::ScriptOptionFlags::Pretty);
+ pretty = true;
}
auto cli = (
@@ -32,7 +34,7 @@ int main(int argc, char *argv[]) {
[&opts] { opts.set(ScriptOptionFlags::KeepGoing); }
),
clipp::option("-n", "--no-colour").doc("Do not 'prettify' output")(
- [&opts] { opts.reset(ScriptOptionFlags::Pretty); }
+ [] { pretty = false; }
),
clipp::option("-s", "--strict").doc("Strict parsing")(
[&opts] { opts.set(ScriptOptionFlags::StrictMode); }
@@ -44,9 +46,9 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
- bold_if_pretty(opts.test(ScriptOptionFlags::Pretty), std::cout);
+ bold_if_pretty(std::cout);
std::cout << "HorizonScript Validation Utility version 0.1.0";
- reset_if_pretty(opts.test(ScriptOptionFlags::Pretty), std::cout);
+ reset_if_pretty(std::cout);
std::cout << std::endl;
std::cout << "Copyright (c) 2019 Adélie Linux and contributors. AGPL-3.0 license." << std::endl;
std::cout << std::endl;
@@ -58,10 +60,10 @@ int main(int argc, char *argv[]) {
}
if(!my_script->validate()) {
- output_error("installfile", "Script failed validation step. Stop.", "", true);
+ output_error("installfile", "Script failed validation step. Stop.", "");
result_code = EXIT_FAILURE;
} else {
- output_info("installfile", "Script passed validation.", "", true);
+ output_info("installfile", "Script passed validation.", "");
}
delete my_script;