summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fetch/fetch.cc13
-rw-r--r--image/creator.13
-rw-r--r--image/creator.cc20
-rw-r--r--tools/hscript-fromjson/jsonconv.15
-rw-r--r--tools/hscript-fromjson/jsonconv.cc16
-rw-r--r--tools/hscript-simulate/simulator.16
-rw-r--r--tools/hscript-simulate/simulator.cc76
-rw-r--r--tools/hscript-validate/validator.16
-rw-r--r--tools/hscript-validate/validator.cc84
-rw-r--r--ui/qt5/CMakeLists.txt2
-rw-r--r--ui/qt5/main.cc24
11 files changed, 173 insertions, 82 deletions
diff --git a/fetch/fetch.cc b/fetch/fetch.cc
index b1a9f56..25e13bc 100644
--- a/fetch/fetch.cc
+++ b/fetch/fetch.cc
@@ -173,9 +173,12 @@ int main(int argc, char *argv[]) {
bold_if_pretty(std::cout);
std::cout << "HorizonScript Locator version " << VERSTR;
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;
+ std::cout << std::endl
+ << "Copyright (c) 2019-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;
if(argc == 1) {
if(access(IFILE_PATH, F_OK) == 0) {
@@ -195,6 +198,10 @@ int main(int argc, char *argv[]) {
}
std::string path(argv[1]);
+ if(path == "--version") {
+ /* Banner printed above is our version statement. */
+ return EXIT_SUCCESS;
+ }
if(path[0] == '/') {
return process_local(path);
diff --git a/image/creator.1 b/image/creator.1
index 0a5a916..5673f75 100644
--- a/image/creator.1
+++ b/image/creator.1
@@ -11,6 +11,7 @@
.Op Fl n
.Op Fl o Ar OUTPUT-FILE
.Op Fl t Ar TYPE
+.Op Fl v
.Op Ar INSTALLFILE
.Sh DESCRIPTION
The
@@ -77,6 +78,8 @@ utility can be obtained by specifying
.Cm list
as the argument to
.Fl t .
+.It Fl v
+Displays the version information for this utility, and then exits.
.It Ar INSTALLFILE
Specifies the location of the HorizonScript to use for configuring the image.
You may specify
diff --git a/image/creator.cc b/image/creator.cc
index 805e13b..c83c597 100644
--- a/image/creator.cc
+++ b/image/creator.cc
@@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
using namespace boost::program_options;
using namespace Horizon::Image;
- bool needs_help{}, disable_pretty{};
+ bool needs_help{}, disable_pretty{}, version_only{};
int exit_code = EXIT_SUCCESS;
std::string if_path{"/etc/horizon/installfile"}, ir_dir{"/target"},
output_path{"image.tar"}, type_code{"tar"};
@@ -42,7 +42,8 @@ int main(int argc, char *argv[]) {
options_description general{"General options"};
general.add_options()
("help,h", bool_switch(&needs_help), "Display this message.")
- ("no-colour,n", bool_switch(&disable_pretty), "Do not 'prettify' output")
+ ("no-colour,n", bool_switch(&disable_pretty), "Do not 'prettify' output.")
+ ("version,v", bool_switch(&version_only), "Show program version information.")
;
options_description target{"Target control options"};
target.add_options()
@@ -113,12 +114,19 @@ int main(int argc, char *argv[]) {
}
/* Announce our presence */
+ bold_if_pretty(std::cout);
std::cout << "HorizonScript Image Creation Utility version " << VERSTR
+ << std::endl;
+ reset_if_pretty(std::cout);
+ std::cout << "Copyright (c) 2020 Adélie Linux and contributors."
<< std::endl
- << "Copyright (c) 2020 Adélie Linux and contributors."
- << std::endl
- << "This software is licensed to you under the AGPL 3.0, "
- << "unless otherwise noted." << std::endl << 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;
+
+ if(version_only) {
+ return EXIT_SUCCESS;
+ }
/* Load the proper backend. */
for(const auto &candidate : BackendManager::available_backends()) {
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;
diff --git a/tools/hscript-simulate/simulator.1 b/tools/hscript-simulate/simulator.1
index d6a30b5..bad08a1 100644
--- a/tools/hscript-simulate/simulator.1
+++ b/tools/hscript-simulate/simulator.1
@@ -6,7 +6,7 @@
.Nd simulate execution of a HorizonScript, or create shell script
.Sh SYNOPSIS
.Nm
-.Op Fl ns
+.Op Fl hnsv
.Ar INSTALLFILE
.Sh DESCRIPTION
The
@@ -24,12 +24,16 @@ The
.Nm
utility supports the following options:
.Bl -tag -width Ds
+.It Fl h
+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 s
Enables Strict mode, which causes more potential issues to be errors instead
of warnings.
+.It Fl v
+Displays the version information for this utility, and then exits.
.El
.Sh EXIT STATUS
.Ex -std
diff --git a/tools/hscript-simulate/simulator.cc b/tools/hscript-simulate/simulator.cc
index 1731c62..ade54dc 100644
--- a/tools/hscript-simulate/simulator.cc
+++ b/tools/hscript-simulate/simulator.cc
@@ -14,19 +14,18 @@
#include "hscript/script.hh"
#include "util/output.hh"
+
bool pretty = false;
-static int cli_failure(boost::program_options::options_description cli) {
- std::cout << cli << std::endl;
- return EXIT_FAILURE;
-}
int main(int argc, char *argv[]) {
const Horizon::Script *my_script;
Horizon::ScriptOptions opts;
int result_code = EXIT_SUCCESS;
std::string installfile;
+ bool strict{}, needs_help{}, disable_pretty{}, version_only{};
using Horizon::ScriptOptionFlags;
+ using namespace boost::program_options;
/* Default to pretty if we are using a TTY, unless -n specified. */
if(isatty(1) && isatty(2)) {
@@ -35,42 +34,44 @@ int main(int argc, char *argv[]) {
opts.set(ScriptOptionFlags::Simulate);
- boost::program_options::options_description cli_hidden;
+ options_description cli_hidden;
cli_hidden.add_options()
("installfile", "Installfile to load");
- boost::program_options::options_description cli_visible("Allowed options");
+ options_description cli_visible("Allowed options");
cli_visible.add_options()
- ("no-colour,n", "Do not 'prettify' output")
- ("strict,s", "Strict parsing");
- boost::program_options::options_description cli;
+ ("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.")
+ ("strict,s", bool_switch(&strict), "Use strict parsing mode (enable more warnings/errors).");
+ options_description cli;
cli.add(cli_visible).add(cli_hidden);
- boost::program_options::positional_options_description cli_pos;
+ positional_options_description cli_pos;
cli_pos.add("installfile", -1);
- boost::program_options::variables_map args;
+ variables_map args;
try {
- boost::program_options::store(
- boost::program_options::command_line_parser(argc, argv)
+ store(
+ command_line_parser(argc, argv)
.options(cli)
.positional(cli_pos)
.run(),
args);
- boost::program_options::notify(args);
+ notify(args);
} catch(const boost::program_options::error& cli_err) {
- std::cout << "An invalid option was entered." << std::endl;
- return cli_failure(cli_visible);
+ std::cerr << cli_err.what() << std::endl;
+ needs_help = true;
+ result_code = EXIT_FAILURE;
}
- if (args.count("installfile")) {
- installfile = args["installfile"].as<std::string>();
- } else {
- std::cout << "You must provide an installfile." << std::endl;
- return cli_failure(cli_visible);
+ if(needs_help) {
+ std::cout << cli_visible << std::endl;
+ return result_code;
}
- if (args.count("no-colour")) {
+ if(disable_pretty) {
pretty = false;
}
- if (args.count("strict")) {
+
+ if(strict) {
opts.set(ScriptOptionFlags::StrictMode);
}
@@ -86,28 +87,39 @@ int main(int argc, char *argv[]) {
#ifdef NON_LIBRE_FIRMWARE
colour_if_pretty(std::cout, "31");
std::cout << " (supports non-free firmware)";
- reset_if_pretty(std::cout);
#endif
+ reset_if_pretty(std::cout);
std::cout << std::endl;
if(isatty(1)) { /* LCOV_EXCL_START */
- std::cout << "Copyright (c) 2019-2020 Adélie Linux and contributors.";
- std::cout << std::endl;
- std::cout << "This software is licensed to you under the terms of the "
- << std::endl << "AGPL 3.0 license, unless otherwise noted.";
- std::cout << std::endl << std::endl;
+ std::cout << "Copyright (c) 2019-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;
} /* LCOV_EXCL_STOP */
+ if(version_only) {
+ return EXIT_SUCCESS;
+ }
+
+ if(args.count("installfile")) {
+ installfile = args["installfile"].as<std::string>();
+ } else {
+ output_error("<stdin>", "You must specify an installfile");
+ return EXIT_FAILURE;
+ }
+
my_script = Horizon::Script::load(installfile, opts);
if(my_script == nullptr) {
- std::cout << "Could not load the specified script." << std::endl;
+ output_error(installfile, "Could not load the specified script");
return EXIT_FAILURE;
}
if(!my_script->execute()) {
- output_error("internal", "Script failed. Stop.", "");
+ output_error("internal", "Script failed. Stop.");
result_code = EXIT_FAILURE;
} else {
- output_info("internal", "Script completed successfully.", "");
+ output_info("internal", "Script completed successfully.");
}
delete my_script;
diff --git a/tools/hscript-validate/validator.1 b/tools/hscript-validate/validator.1
index b57a227..9993a0b 100644
--- a/tools/hscript-validate/validator.1
+++ b/tools/hscript-validate/validator.1
@@ -6,7 +6,7 @@
.Nd ensure the validity of a HorizonScript
.Sh SYNOPSIS
.Nm
-.Op Fl ikns
+.Op Fl hiknsv
.Ar INSTALLFILE
.Sh DESCRIPTION
The
@@ -18,6 +18,8 @@ The
.Nm
utility supports the following options:
.Bl -tag -width Ds
+.It Fl h
+Displays a help message, and then exits.
.It Fl i
Set the Installation Environment flag. This is VERY DANGEROUS, as it will
treat your host system as the target for purposes of validation. Unless you
@@ -31,6 +33,8 @@ is the default when not running from a terminal.
.It Fl s
Enables Strict mode, which causes more potential issues to be errors instead
of warnings.
+.It Fl v
+Displays the version information for this utility, and then exits.
.El
.Sh EXIT STATUS
.Ex -std
diff --git a/tools/hscript-validate/validator.cc b/tools/hscript-validate/validator.cc
index 77641c7..8277bea 100644
--- a/tools/hscript-validate/validator.cc
+++ b/tools/hscript-validate/validator.cc
@@ -14,69 +14,70 @@
#include "hscript/script.hh"
#include "util/output.hh"
+
bool pretty = false;
-static int cli_failure(boost::program_options::options_description cli) {
- std::cout << cli << std::endl;
- return EXIT_FAILURE;
-}
int main(int argc, char *argv[]) {
const Horizon::Script *my_script;
Horizon::ScriptOptions opts;
int result_code = EXIT_SUCCESS;
std::string installfile;
+ bool install{}, keep_going{}, strict{}, needs_help{}, version_only{},
+ dont_pretty{};
using Horizon::ScriptOptionFlags;
+ using namespace boost::program_options;
/* Default to pretty if we are using a TTY, unless -n specified. */
if(isatty(1) && isatty(2)) {
pretty = true; /* LCOV_EXCL_LINE */
}
- boost::program_options::options_description cli_hidden;
+ options_description cli_hidden;
cli_hidden.add_options()
("installfile", "Installfile to load");
- boost::program_options::options_description cli_visible("Allowed options");
+ options_description cli_visible("Allowed options");
cli_visible.add_options()
- ("install,i", "Set Installation Environment flag (DANGEROUS)")
- ("keep-going,k", "Continue parsing after errors")
- ("no-colour,n", "Do not 'prettify' output")
- ("strict,s", "Strict parsing");
- boost::program_options::options_description cli;
+ ("help,h", bool_switch(&needs_help), "Display this message.")
+ ("version,v", bool_switch(&version_only), "Show program version information.")
+ ("install,i", bool_switch(&install), "Set Installation Environment flag. (DANGEROUS!)")
+ ("keep-going,k", bool_switch(&keep_going), "Continue parsing after errors.")
+ ("no-colour,n", bool_switch(&dont_pretty), "Do not 'prettify' output.")
+ ("strict,s", bool_switch(&strict), "Use strict parsing mode (enable more warnings/errors).");
+ options_description cli;
cli.add(cli_visible).add(cli_hidden);
- boost::program_options::positional_options_description cli_pos;
+ positional_options_description cli_pos;
cli_pos.add("installfile", -1);
- boost::program_options::variables_map args;
+ variables_map args;
try {
- boost::program_options::store(
- boost::program_options::command_line_parser(argc, argv)
+ store(
+ command_line_parser(argc, argv)
.options(cli)
.positional(cli_pos)
.run(),
args);
- boost::program_options::notify(args);
+ notify(args);
} catch(const boost::program_options::error& cli_err) {
std::cout << "An invalid option was entered." << std::endl;
- return cli_failure(cli_visible);
+ needs_help = true;
+ result_code = EXIT_FAILURE;
}
- if (args.count("installfile")) {
- installfile = args["installfile"].as<std::string>();
- } else {
- std::cout << "You must provide an installfile." << std::endl;
- return cli_failure(cli_visible);
+ if(needs_help) {
+ std::cout << cli_visible << std::endl;
+ return result_code;
}
- if (args.count("install")) {
+ if(install) {
opts.set(ScriptOptionFlags::InstallEnvironment);
}
- if (args.count("keep-going")) {
+ if(keep_going) {
opts.set(ScriptOptionFlags::KeepGoing);
}
- if (args.count("no-colour")) {
+ if(dont_pretty) {
pretty = false;
}
- if (args.count("strict")) {
+ if(strict) {
opts.set(ScriptOptionFlags::StrictMode);
}
@@ -88,26 +89,37 @@ int main(int argc, char *argv[]) {
#ifdef NON_LIBRE_FIRMWARE
colour_if_pretty(std::cout, "31");
std::cout << " (supports non-free firmware)";
- reset_if_pretty(std::cout);
#endif
- std::cout << std::endl;
- std::cout << "Copyright (c) 2019-2020 Adélie Linux and contributors."
- << std::endl;
- std::cout << "This software is licensed to you under the terms of the "
- << std::endl << "AGPL 3.0 license, unless otherwise noted.";
- std::cout << std::endl << std::endl;
+ reset_if_pretty(std::cout);
+ std::cout << std::endl
+ << "Copyright (c) 2019-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;
+
+ if(version_only) {
+ return EXIT_SUCCESS;
+ }
+
+ if(args.count("installfile")) {
+ installfile = args["installfile"].as<std::string>();
+ } else {
+ output_error("<stdin>", "You must specify an installfile");
+ return EXIT_FAILURE;
+ }
my_script = Horizon::Script::load(installfile, opts);
if(my_script == nullptr) {
- std::cout << "Could not load the specified script." << std::endl;
+ output_error(installfile, "Could not load the specified script");
return EXIT_FAILURE;
}
if(!my_script->validate()) {
- output_error("internal", "Script failed validation. Stop.", "");
+ output_error("internal", "Script failed validation. Stop.");
result_code = EXIT_FAILURE;
} else {
- output_info("internal", "Script passed validation.", "");
+ output_info("internal", "Script passed validation.");
}
delete my_script;
diff --git a/ui/qt5/CMakeLists.txt b/ui/qt5/CMakeLists.txt
index 8dbf4a8..f8bdb56 100644
--- a/ui/qt5/CMakeLists.txt
+++ b/ui/qt5/CMakeLists.txt
@@ -84,6 +84,6 @@ IF(INSTALL)
ENDIF()
install(TARGETS horizon-run-qt5 DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/horizon-run-qt5.8 DESTINATION share/man/man8)
- install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/horizon-ppc64-detect DESTINATION bin)
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/horizon-ppc64-detect DESTINATION bin)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/horizon-ppc64-detect.1 DESTINATION share/man/man1)
ENDIF(INSTALL)
diff --git a/ui/qt5/main.cc b/ui/qt5/main.cc
index 330311f..22ef39e 100644
--- a/ui/qt5/main.cc
+++ b/ui/qt5/main.cc
@@ -11,6 +11,7 @@
*/
#include <QApplication>
+#include <QCommandLineParser>
#include <QDialog>
#include <QIcon>
#include <QLabel>
@@ -44,6 +45,9 @@ void WaitDialog::reject() { return; }
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
+ app.setOrganizationName("Adélie Linux");
+ app.setApplicationName("Horizon Qt UI");
+ app.setApplicationVersion(VERSTR);
QString translatorFileName = QLatin1String("qt_");
translatorFileName += QLocale::system().name();
@@ -62,6 +66,26 @@ int main(int argc, char *argv[]) {
app.setWindowIcon(QIcon(":/horizon-256.png"));
+ QCommandLineParser parser;
+ parser.setApplicationDescription(app.tr("Guides the user through creation of a HorizonScript."));
+ QCommandLineOption help = parser.addHelpOption();
+ QCommandLineOption version = parser.addVersionOption();
+
+ if(!parser.parse(app.arguments())) {
+ parser.showHelp(1);
+ return 1;
+ }
+
+ if(parser.isSet(help)) {
+ parser.showHelp();
+ return 0;
+ }
+
+ if(parser.isSet(version)) {
+ parser.showVersion();
+ return 0;
+ }
+
HorizonWizard wizard;
d.hide();
app.restoreOverrideCursor();