diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-05-17 03:08:54 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-05-17 03:08:54 -0500 |
commit | 6eba782291a999e4577bc8d3386f0dcb6945e6a4 (patch) | |
tree | 1c3d48203bc6d335df0b284c5a6f692c3fcbc5eb /image | |
parent | a6b3b0f6cbaeb90995f5aa14eca7e27d9ff218e2 (diff) | |
download | horizon-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 'image')
-rw-r--r-- | image/creator.1 | 3 | ||||
-rw-r--r-- | image/creator.cc | 20 |
2 files changed, 17 insertions, 6 deletions
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()) { |