From 215099e106f30894a9fb0104515dbc75f94e66cd Mon Sep 17 00:00:00 2001 From: Tom Dewey Date: Tue, 30 Apr 2024 14:24:02 +0100 Subject: [PATCH] cli: Add disable-eject, rework options specification --- src/cli.cpp | 66 +++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/src/cli.cpp b/src/cli.cpp index 97f00e8..61059aa 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -49,27 +49,19 @@ Cli::~Cli() int Cli::main() { QCommandLineParser parser; - QCommandLineOption cli("cli"); - parser.addOption(cli); - QCommandLineOption disableVerify("disable-verify", "Disable verification"); - parser.addOption(disableVerify); - QCommandLineOption writeSystemDrive("enable-writing-system-drives", "Only use this if you know what you are doing"); - parser.addOption(writeSystemDrive); - QCommandLineOption sha256Option("sha256", "Expected hash", "sha256", ""); - parser.addOption(sha256Option); - QCommandLineOption cacheFileOption("cache-file", "Custom cache file (requires setting sha256 as well)", "cache-file", ""); - parser.addOption(cacheFileOption); - QCommandLineOption firstRunScriptOption("first-run-script", "Add firstrun.sh to image", "first-run-script", ""); - parser.addOption(firstRunScriptOption); - QCommandLineOption userdataOption("cloudinit-userdata", "Add cloud-init user-data file to image", "cloudinit-userdata", ""); - parser.addOption(userdataOption); - QCommandLineOption networkconfigOption("cloudinit-networkconfig", "Add cloud-init network-config file to image", "cloudinit-networkconfig", ""); - parser.addOption(networkconfigOption); - - QCommandLineOption debugOption("debug", "Output debug messages to console"); - parser.addOption(debugOption); - QCommandLineOption quietOption("quiet", "Only write to console on error"); - parser.addOption(quietOption); + parser.addOptions({ + {"cli", ""}, + {"disable-verify", "Disable verification"}, + {"enable-writing-system-drives", "Only use this if you know what you are doing"}, + {"sha256", "Expected hash", "sha256", ""}, + {"cache-file", "Custom cache file (requires setting sha256 as well)", "cache-file", ""}, + {"first-run-script", "Add firstrun.sh to image", "first-run-script", ""}, + {"cloudinit-userdata", "Add cloud-init user-data file to image", "cloudinit-userdata", ""}, + {"cloudinit-networkconfig", "Add cloud-init network-config file to image", "cloudinit-networkconfig", ""}, + {"disable-eject", "Disable automatic ejection of storage media after verification"}, + {"debug", "Output debug messages to console"}, + {"quiet", "Only write to console on error"}, + }); parser.addPositionalArgument("src", "Image file/URL"); parser.addPositionalArgument("dst", "Destination device"); @@ -78,25 +70,25 @@ int Cli::main() const QStringList args = parser.positionalArguments(); if (args.count() != 2) { - std::cerr << "Usage: --cli [--disable-verify] [--sha256 [--cache-file ]] [--first-run-script