trivial: fu-tool: Allow detach/attach to prompt for device

Makes using `fwupdtool detach` easier to use.
This commit is contained in:
Mario Limonciello 2019-10-22 08:37:45 -05:00 committed by Mario Limonciello
parent 77606cc3b8
commit a61b4d88c9

View File

@ -486,8 +486,6 @@ fu_util_prompt_for_device (FuUtilPrivate *priv, GError **error)
dev = g_ptr_array_index (devices, i); dev = g_ptr_array_index (devices, i);
if (!fu_util_filter_device (priv, FWUPD_DEVICE (dev))) if (!fu_util_filter_device (priv, FWUPD_DEVICE (dev)))
continue; continue;
if (!fwupd_device_has_flag (FWUPD_DEVICE (dev), FWUPD_DEVICE_FLAG_SUPPORTED))
continue;
g_ptr_array_add (devices_filtered, g_object_ref (dev)); g_ptr_array_add (devices_filtered, g_object_ref (dev));
} }
@ -503,6 +501,8 @@ fu_util_prompt_for_device (FuUtilPrivate *priv, GError **error)
/* exactly one */ /* exactly one */
if (devices_filtered->len == 1) { if (devices_filtered->len == 1) {
dev = g_ptr_array_index (devices_filtered, 0); dev = g_ptr_array_index (devices_filtered, 0);
/* TRANSLATORS: Device has been chosen by the daemon for the user */
g_print ("%s: %s\n", _("Selected device"), fu_device_get_name (dev));
return g_object_ref (dev); return g_object_ref (dev);
} }
@ -990,15 +990,6 @@ fu_util_detach (FuUtilPrivate *priv, gchar **values, GError **error)
if (!fu_util_start_engine (priv, FU_ENGINE_LOAD_FLAG_NONE, error)) if (!fu_util_start_engine (priv, FU_ENGINE_LOAD_FLAG_NONE, error))
return FALSE; return FALSE;
/* invalid args */
if (g_strv_length (values) == 0) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_ARGS,
"Invalid arguments");
return FALSE;
}
/* get device */ /* get device */
if (g_strv_length (values) >= 1) { if (g_strv_length (values) >= 1) {
device = fu_engine_get_device (priv->engine, values[0], error); device = fu_engine_get_device (priv->engine, values[0], error);
@ -1027,15 +1018,6 @@ fu_util_attach (FuUtilPrivate *priv, gchar **values, GError **error)
if (!fu_util_start_engine (priv, FU_ENGINE_LOAD_FLAG_NONE, error)) if (!fu_util_start_engine (priv, FU_ENGINE_LOAD_FLAG_NONE, error))
return FALSE; return FALSE;
/* invalid args */
if (g_strv_length (values) == 0) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_ARGS,
"Invalid arguments");
return FALSE;
}
/* get device */ /* get device */
if (g_strv_length (values) >= 1) { if (g_strv_length (values) >= 1) {
device = fu_engine_get_device (priv->engine, values[0], error); device = fu_engine_get_device (priv->engine, values[0], error);