diff --git a/src/fu-tool.c b/src/fu-tool.c index 34622aa39..36452f047 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -66,6 +66,7 @@ struct FuUtilPrivate { gboolean as_json; gboolean no_reboot_check; gboolean no_safety_check; + gboolean no_device_prompt; gboolean prepare_blob; gboolean cleanup_blob; gboolean enable_json_state; @@ -534,6 +535,15 @@ fu_util_prompt_for_device(FuUtilPrivate *priv, GPtrArray *devices_opt, GError ** return g_object_ref(dev); } + /* no questions */ + if (priv->no_device_prompt) { + g_set_error_literal(error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_FOUND, + "can't prompt for devices"); + return NULL; + } + /* TRANSLATORS: get interactive prompt */ g_print("%s\n", _("Choose a device:")); /* TRANSLATORS: this is to abort the interactive prompt */ @@ -3219,6 +3229,14 @@ main(int argc, char *argv[]) /* TRANSLATORS: command line option */ N_("Do not perform device safety checks"), NULL}, + {"no-device-prompt", + '\0', + 0, + G_OPTION_ARG_NONE, + &priv->no_device_prompt, + /* TRANSLATORS: command line option */ + N_("Do not prompt for devices"), + NULL}, {"show-all", '\0', 0, @@ -3618,6 +3636,7 @@ main(int argc, char *argv[]) g_debug("failed to initialize interactive console: %s", error_console->message); priv->no_reboot_check = TRUE; priv->no_safety_check = TRUE; + priv->no_device_prompt = TRUE; } else { priv->interactive = TRUE; /* set our implemented feature set */ diff --git a/src/fu-util.c b/src/fu-util.c index e393ccdba..4011371ae 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -62,6 +62,7 @@ struct FuUtilPrivate { gboolean no_reboot_check; gboolean no_unreported_check; gboolean no_safety_check; + gboolean no_device_prompt; gboolean assume_yes; gboolean sign; gboolean show_all; @@ -211,6 +212,15 @@ fu_util_prompt_for_device(FuUtilPrivate *priv, GPtrArray *devices, GError **erro return g_object_ref(dev); } + /* no questions */ + if (priv->no_device_prompt) { + g_set_error_literal(error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_FOUND, + "can't prompt for devices "); + return NULL; + } + /* TRANSLATORS: get interactive prompt */ g_print("%s\n", _("Choose a device:")); /* TRANSLATORS: this is to abort the interactive prompt */ @@ -3890,6 +3900,14 @@ main(int argc, char *argv[]) /* TRANSLATORS: command line option */ N_("Do not perform device safety checks"), NULL}, + {"no-device-prompt", + '\0', + 0, + G_OPTION_ARG_NONE, + &priv->no_device_prompt, + /* TRANSLATORS: command line option */ + N_("Do not prompt for devices"), + NULL}, {"no-history", '\0', 0, @@ -4259,6 +4277,7 @@ main(int argc, char *argv[]) priv->no_reboot_check = TRUE; priv->no_safety_check = TRUE; priv->no_remote_check = TRUE; + priv->no_device_prompt = TRUE; } else { is_interactive = TRUE; }