cli: refactor property to string conversion

Instead of having a get_func() and out2in_func(), have only one
get_func() that accepts an argument of the output format.

This way, a conversion to parsable input format, doesn't have to go
first thourgh get_func() and mangle the pretty string in out2in_func().

This fixes conversions via nmc_property_out2in_cut_paren().
For example, nmc_property_802_1X_get_private_key_password_flags()
would return a localized string _("0 (none)"). There is no guarantee
that out2in_func() would find the expected output format after
localizing.

This also fixes nmc_property_out2in_routes() which expected
a format "dst =" (would be "ip =") and expects mandatory
'nh' and 'mt' arguments. In fact, the regex didn't match and
nmc_property_out2in_routes() always failed.

While at it, also combine the implementation of
nmc_property_ipv4_get_routes() and nmc_property_ipv6_get_routes().

(cherry picked from commit 8a14851f93)
This commit is contained in:
Thomas Haller 2015-05-21 13:00:40 +02:00
parent c933bacd4a
commit b81bbc134c
3 changed files with 323 additions and 372 deletions

View file

@ -7221,7 +7221,7 @@ property_edit_submenu (NmCli *nmc,
case NMC_EDITOR_SUB_CMD_CHANGE:
rl_startup_hook = nmc_rl_set_deftext;
nmc_rl_pre_input_deftext = nmc_setting_get_property_out2in (curr_setting, prop_name, NULL);
nmc_rl_pre_input_deftext = nmc_setting_get_property_parsable (curr_setting, prop_name, NULL);
prop_val_user = nmc_readline (_("Edit '%s' value: "), prop_name);
nmc_property_get_gvalue (curr_setting, prop_name, &prop_g_value);

File diff suppressed because it is too large Load diff

View file

@ -41,9 +41,9 @@ const char **nmc_setting_get_property_allowed_values (NMSetting *setting, const
char *nmc_setting_get_property (NMSetting *setting,
const char *prop,
GError **error);
char *nmc_setting_get_property_out2in (NMSetting *setting,
const char *prop,
GError **error);
char *nmc_setting_get_property_parsable (NMSetting *setting,
const char *prop,
GError **error);
gboolean nmc_setting_set_property (NMSetting *setting,
const char *prop,
const char *val,