From 6eba782291a999e4577bc8d3386f0dcb6945e6a4 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 17 May 2020 03:08:54 -0500 Subject: all: Add --version and --help support and unify output formats --- image/creator.1 | 3 +++ image/creator.cc | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'image') 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()) { -- cgit v1.2.3-60-g2f50