From 370c667887a810fb28df392f4c8e4418ebb8b1a2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 21 Jan 2019 14:39:08 -0500 Subject: [PATCH] columns: Be more precise and helpful Complain about ambiguous suffixes, and and spell out the allowed values when complaining about suffixes. Closes: #2624 Approved by: matthiasclasen --- app/flatpak-builtins-utils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/flatpak-builtins-utils.c b/app/flatpak-builtins-utils.c index 7e7844b3..8a09006d 100644 --- a/app/flatpak-builtins-utils.c +++ b/app/flatpak-builtins-utils.c @@ -824,7 +824,14 @@ parse_ellipsize_suffix (const char *p, FlatpakEllipsizeMode *mode, GError **error) { - if (g_str_has_prefix (":full", p)) + if (g_str_equal (":", p)) + { + g_autofree char *msg1 = g_strdup_printf (_("Ambiguous suffix: '%s'."), p); + /* Translators: don't translate the values */ + const char *msg2 = _("Possible values are :s[tart], :m[iddle], :e[nd] or :f[ull]"); + return flatpak_fail (error, "%s %s", msg1, msg2); + } + else if (g_str_has_prefix (":full", p)) *mode = FLATPAK_ELLIPSIZE_MODE_NONE; else if (g_str_has_prefix (":start", p)) *mode = FLATPAK_ELLIPSIZE_MODE_START; @@ -833,7 +840,12 @@ parse_ellipsize_suffix (const char *p, else if (g_str_has_prefix (":end", p)) *mode = FLATPAK_ELLIPSIZE_MODE_END; else - return flatpak_fail (error, "'%s' does not specify an ellipsization", p); + { + g_autofree char *msg1 = g_strdup_printf (_("Invalid suffix: '%s'."), p); + /* Translators: don't translate the values */ + const char *msg2 = _("Possible values are :s[tart], :m[iddle], :e[nd] or :f[ull]"); + return flatpak_fail (error, "%s %s", msg1, msg2); + } return TRUE; }