cli: editor 'change' command: output -> input format conversion (rh #998929)
The format of property values that nmcli prints is not the same (for some properties) as the format nmcli editor accepts as input from user. The reasons are that (a) output format is more descriptive and not much suitable to be typed, (b) it comes in most cases from libnm-util. 'change' command displays current property value and allows users to edit it. So we convert the output into input format, before presenting it to the user. https://bugzilla.redhat.com/show_bug.cgi?id=998929
This commit is contained in:
@@ -4321,6 +4321,7 @@ set_deftext (void)
|
||||
&& edit_lib_symbols.rl_insert_text_func
|
||||
&& edit_lib_symbols.rl_startup_hook_x) {
|
||||
edit_lib_symbols.rl_insert_text_func (pre_input_deftext);
|
||||
g_free (pre_input_deftext);
|
||||
pre_input_deftext = NULL;
|
||||
*edit_lib_symbols.rl_startup_hook_x = NULL;
|
||||
}
|
||||
@@ -5301,7 +5302,7 @@ property_edit_submenu (NmCli *nmc,
|
||||
|
||||
case NMC_EDITOR_SUB_CMD_CHANGE:
|
||||
*edit_lib_symbols.rl_startup_hook_x = set_deftext;
|
||||
pre_input_deftext = nmc_setting_get_property (curr_setting, prop_name, NULL);
|
||||
pre_input_deftext = nmc_setting_get_property_out2in (curr_setting, prop_name, NULL);
|
||||
tmp_prompt = g_strdup_printf (_("Edit '%s' value: "), prop_name);
|
||||
prop_val_user = readline_x (tmp_prompt);
|
||||
|
||||
@@ -5360,9 +5361,9 @@ property_edit_submenu (NmCli *nmc,
|
||||
else
|
||||
printf (_("Unknown command argument: '%s'\n"), cmd_property_arg);
|
||||
} else {
|
||||
printf ("%s: %s\n",
|
||||
prop_name,
|
||||
nmc_setting_get_property (curr_setting, prop_name, NULL));
|
||||
char *prop_val = nmc_setting_get_property (curr_setting, prop_name, NULL);
|
||||
printf ("%s: %s\n", prop_name, prop_val);
|
||||
g_free (prop_val);
|
||||
}
|
||||
break;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -62,6 +62,9 @@ const char *nmc_setting_get_property_allowed_values (NMSetting *setting, const c
|
||||
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);
|
||||
gboolean nmc_setting_set_property (NMSetting *setting,
|
||||
const char *prop,
|
||||
const char *val,
|
||||
|
Reference in New Issue
Block a user