summaryrefslogtreecommitdiff
path: root/tools/hscript-fromjson
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
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')
-rw-r--r--tools/hscript-fromjson/jsonconv.15
-rw-r--r--tools/hscript-fromjson/jsonconv.cc16
2 files changed, 19 insertions, 2 deletions
diff --git a/tools/hscript-fromjson/jsonconv.1 b/tools/hscript-fromjson/jsonconv.1
index d8fe22e..a05a67f 100644
--- a/tools/hscript-fromjson/jsonconv.1
+++ b/tools/hscript-fromjson/jsonconv.1
@@ -8,6 +8,7 @@
.Nm
.Op Fl fn
.Op Fl h
+.Op Fl v
.Op Ar INSTALLFILE
.Op Ar JSONFILE
.Sh DESCRIPTION
@@ -36,10 +37,12 @@ exists. By default,
will display an error and quit without writing if a HorizonScript already
exists at the specified path.
.It Fl h
-Display a help message, and then quit.
+Displays a help message, and then exits.
.It Fl n
Disables colour output and ANSI escape sequences in any log messages. This
is the default when not running from a terminal.
+.It Fl v
+Displays the version information for this utility, and then exits.
.El
.Sh EXIT STATUS
.Ex -std
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;