summaryrefslogtreecommitdiff
path: root/tools/hscript-fromjson/jsonconv.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-17 03:08:54 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-17 03:08:54 -0500
commit6eba782291a999e4577bc8d3386f0dcb6945e6a4 (patch)
tree1c3d48203bc6d335df0b284c5a6f692c3fcbc5eb /tools/hscript-fromjson/jsonconv.cc
parenta6b3b0f6cbaeb90995f5aa14eca7e27d9ff218e2 (diff)
downloadhorizon-6eba782291a999e4577bc8d3386f0dcb6945e6a4.tar.gz
horizon-6eba782291a999e4577bc8d3386f0dcb6945e6a4.tar.bz2
horizon-6eba782291a999e4577bc8d3386f0dcb6945e6a4.tar.xz
horizon-6eba782291a999e4577bc8d3386f0dcb6945e6a4.zip
all: Add --version and --help support and unify output formats
Diffstat (limited to 'tools/hscript-fromjson/jsonconv.cc')
-rw-r--r--tools/hscript-fromjson/jsonconv.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/hscript-fromjson/jsonconv.cc b/tools/hscript-fromjson/jsonconv.cc
index 3a5c564..b5c9504 100644
--- a/tools/hscript-fromjson/jsonconv.cc
+++ b/tools/hscript-fromjson/jsonconv.cc
@@ -146,7 +146,7 @@ bool parse_one_desc(json desc, std::ostream &out) {
int main(int argc, char *argv[]) {
using namespace boost::program_options;
- bool needs_help{}, disable_pretty{}, force{};
+ bool needs_help{}, disable_pretty{}, force{}, version_only{};
std::string if_path{"/etc/horizon/installfile"}, json_path;
int exit_code = EXIT_SUCCESS;
@@ -155,6 +155,7 @@ int main(int argc, char *argv[]) {
options_description general{"General options"};
general.add_options()
("help,h", bool_switch(&needs_help), "Display this message.")
+ ("version,v", bool_switch(&version_only), "Show program version information")
("no-colour,n", bool_switch(&disable_pretty), "Do not 'prettify' output")
("force,f", bool_switch(&force), "Force writing, even if HorizonScript already exists")
;
@@ -205,6 +206,19 @@ int main(int argc, char *argv[]) {
json_path = "-";
}
+ if(version_only) {
+ bold_if_pretty(std::cout);
+ std::cout << "HorizonScript JSON Conversion Utility version " << VERSTR
+ << std::endl;
+ reset_if_pretty(std::cout);
+ std::cout << "Copyright (c) 2020 Adélie Linux and contributors."
+ << std::endl
+ << "This software is licensed to you under the terms of the "
+ << std::endl << "AGPL 3.0 license, unless otherwise noted."
+ << std::endl << std::endl;
+ return EXIT_SUCCESS;
+ }
+
if(!force && fs::exists(if_path)) {
output_error("<option>", "installfile already exists", if_path);
return EXIT_FAILURE;