mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 07:40:28 +01:00
nmcli/connections: use the current value in default in ask_option()
For new connections, this ensures the value in square brackets on interactive add are always correct. Apart from that, this allows us to initialize some non-default values before asking (such as making up an interface name for some software devices), and inform the user about what we picked: Interface name [nm-bridge]:
This commit is contained in:
parent
ad7ac866db
commit
b171dcec0d
3 changed files with 57 additions and 37 deletions
|
|
@ -4456,7 +4456,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "primary",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding primary interface [none]"),
|
||||
.prompt = N_("Bonding primary interface"),
|
||||
.def_hint = "[none]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4472,7 +4473,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "miimon",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding miimon [100]"),
|
||||
.prompt = N_("Bonding miimon"),
|
||||
.def_hint = "[100]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4480,7 +4482,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "downdelay",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding downdelay [0]"),
|
||||
.prompt = N_("Bonding downdelay"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4488,7 +4491,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "updelay",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding updelay [0]"),
|
||||
.prompt = N_("Bonding updelay"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4496,7 +4500,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "arp-interval",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding arp-interval [0]"),
|
||||
.prompt = N_("Bonding arp-interval"),
|
||||
.def_hint = "[0]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4504,7 +4509,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "arp-ip-target",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("Bonding arp-ip-target [none]"),
|
||||
.prompt = N_("Bonding arp-ip-target"),
|
||||
.def_hint = "[none]",
|
||||
)
|
||||
},
|
||||
{
|
||||
|
|
@ -4512,7 +4518,8 @@ static const NMMetaNestedPropertyInfo meta_nested_property_infos_bond[] = {
|
|||
.property_name = NM_SETTING_BOND_OPTIONS,
|
||||
.property_alias = "lacp-rate",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_DONT_ASK,
|
||||
.prompt = N_("LACP rate ('slow' or 'fast') [slow]"),
|
||||
.prompt = N_("LACP rate (slow/fast)"),
|
||||
.def_hint = "[slow]",
|
||||
)
|
||||
},
|
||||
};
|
||||
|
|
@ -5121,7 +5128,7 @@ static const NMMetaPropertyInfo *const property_infos_BOND_PORT[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BOND_PORT_QUEUE_ID,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "queue-id",
|
||||
.prompt = N_("Queue ID [0]"),
|
||||
.prompt = N_("Queue ID"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -5139,37 +5146,37 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_STP,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "stp",
|
||||
.prompt = N_("Enable STP [yes]"),
|
||||
.prompt = N_("Enable STP"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PRIORITY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "priority",
|
||||
.prompt = N_("STP priority [32768]"),
|
||||
.prompt = N_("STP priority"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_FORWARD_DELAY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "forward-delay",
|
||||
.prompt = N_("Forward delay [15]"),
|
||||
.prompt = N_("Forward delay"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_HELLO_TIME,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "hello-time",
|
||||
.prompt = N_("Hello time [2]"),
|
||||
.prompt = N_("Hello time"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MAX_AGE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "max-age",
|
||||
.prompt = N_("Max age [20]"),
|
||||
.prompt = N_("Max age"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_AGEING_TIME,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "ageing-time",
|
||||
.prompt = N_("MAC address ageing time [300]"),
|
||||
.prompt = N_("MAC address ageing time"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_GROUP_ADDRESS,
|
||||
|
|
@ -5179,7 +5186,7 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "group-forward-mask",
|
||||
.prompt = N_("Group forward mask [0]"),
|
||||
.prompt = N_("Group forward mask"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_HASH_MAX,
|
||||
|
|
@ -5221,7 +5228,7 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_SNOOPING,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "multicast-snooping",
|
||||
.prompt = N_("Enable IGMP snooping [yes]"),
|
||||
.prompt = N_("Enable IGMP snooping"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT,
|
||||
|
|
@ -5279,19 +5286,19 @@ static const NMMetaPropertyInfo *const property_infos_BRIDGE_PORT[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_PRIORITY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "priority",
|
||||
.prompt = N_("Bridge port priority [32]"),
|
||||
.prompt = N_("Bridge port priority"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_PATH_COST,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "path-cost",
|
||||
.prompt = N_("Bridge port STP path cost [100]"),
|
||||
.prompt = N_("Bridge port STP path cost"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "hairpin",
|
||||
.prompt = N_("Hairpin [no]"),
|
||||
.prompt = N_("Hairpin"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_BRIDGE_PORT_VLANS,
|
||||
|
|
@ -5878,7 +5885,7 @@ static const NMMetaPropertyInfo *const property_infos_INFINIBAND[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_INFINIBAND_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingInfiniband, nm_setting_infiniband_get_mtu),
|
||||
|
|
@ -6510,7 +6517,7 @@ static const NMMetaPropertyInfo *const property_infos_MACSEC[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_ENCRYPT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "encrypt",
|
||||
.prompt = N_("Enable encryption [yes]"),
|
||||
.prompt = N_("Enable encryption"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_MKA_CAK,
|
||||
|
|
@ -6532,7 +6539,7 @@ static const NMMetaPropertyInfo *const property_infos_MACSEC[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_PORT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "port",
|
||||
.prompt = N_("SCI port [1]"),
|
||||
.prompt = N_("SCI port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACSEC_VALIDATION,
|
||||
|
|
@ -6579,7 +6586,7 @@ static const NMMetaPropertyInfo *const property_infos_MACVLAN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_MACVLAN_TAP,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "tap",
|
||||
.prompt = N_("Tap [no]"),
|
||||
.prompt = N_("Tap"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -6655,7 +6662,7 @@ static const NMMetaPropertyInfo *const property_infos_OLPC_MESH[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_OLPC_MESH_CHANNEL,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "channel",
|
||||
.prompt = N_("OLPC Mesh channel [1]"),
|
||||
.prompt = N_("OLPC Mesh channel"),
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
.get_fcn = _get_fcn_gobject,
|
||||
.set_fcn = _set_fcn_olpc_mesh_channel,
|
||||
|
|
@ -6881,7 +6888,7 @@ static const NMMetaPropertyInfo *const property_infos_PROXY[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_PROXY_BROWSER_ONLY,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "browser-only",
|
||||
.prompt = N_("Browser only [no]"),
|
||||
.prompt = N_("Browser only"),
|
||||
.property_type = &_pt_gobject_bool
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_PROXY_PAC_URL,
|
||||
|
|
@ -7320,19 +7327,19 @@ static const NMMetaPropertyInfo *const property_infos_TUN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_PI,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "pi",
|
||||
.prompt = N_("Enable PI [no]"),
|
||||
.prompt = N_("Enable PI"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_VNET_HDR,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "vnet-hdr",
|
||||
.prompt = N_("Enable VNET header [no]"),
|
||||
.prompt = N_("Enable VNET header"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_TUN_MULTI_QUEUE,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "multi-queue",
|
||||
.prompt = N_("Enable multi queue [no]"),
|
||||
.prompt = N_("Enable multi queue"),
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -7458,7 +7465,7 @@ static const NMMetaPropertyInfo *const property_infos_VRF[] = {
|
|||
.is_cli_option = TRUE,
|
||||
.property_alias = "table",
|
||||
.inf_flags = NM_META_PROPERTY_INF_FLAG_REQD,
|
||||
.prompt = N_("Table [0]"),
|
||||
.prompt = N_("Table"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
NULL
|
||||
|
|
@ -7496,19 +7503,19 @@ static const NMMetaPropertyInfo *const property_infos_VXLAN[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_SOURCE_PORT_MIN,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "source-port-min",
|
||||
.prompt = N_("Minimum source port [0]"),
|
||||
.prompt = N_("Minimum source port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_SOURCE_PORT_MAX,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "source-port-max",
|
||||
.prompt = N_("Maximum source port [0]"),
|
||||
.prompt = N_("Maximum source port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_DESTINATION_PORT,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "destination-port",
|
||||
.prompt = N_("Destination port [8472]"),
|
||||
.prompt = N_("Destination port"),
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_VXLAN_TOS,
|
||||
|
|
@ -7640,7 +7647,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRED[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRED_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingWired, nm_setting_wired_get_mtu),
|
||||
|
|
@ -7834,7 +7841,7 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_MTU,
|
||||
.is_cli_option = TRUE,
|
||||
.property_alias = "mtu",
|
||||
.prompt = N_("MTU [auto]"),
|
||||
.prompt = N_("MTU"),
|
||||
.property_type = &_pt_gobject_mtu,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (mtu,
|
||||
.get_fcn = MTU_GET_FCN (NMSettingWireless, nm_setting_wireless_get_mtu),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ struct _NMDevice;
|
|||
"(" NM_SETTING_ADSL_ENCAPSULATION_VCMUX "/" NM_SETTING_ADSL_ENCAPSULATION_LLC ") [none]"
|
||||
|
||||
#define NM_META_TEXT_PROMPT_CON_TYPE N_("Connection type")
|
||||
#define NM_META_TEXT_PROMPT_IFNAME N_("Interface name [*]")
|
||||
#define NM_META_TEXT_PROMPT_IFNAME N_("Interface name")
|
||||
#define NM_META_TEXT_PROMPT_VPN_TYPE N_("VPN type")
|
||||
#define NM_META_TEXT_PROMPT_MASTER N_("Master")
|
||||
|
||||
|
|
|
|||
|
|
@ -5575,17 +5575,30 @@ ask_option(NmCli *nmc, NMConnection *connection, const NMMetaAbstractInfo *abstr
|
|||
GError *error = NULL;
|
||||
gs_free char *prompt = NULL;
|
||||
gboolean multi;
|
||||
const char *setting_name, *property_name;
|
||||
const char *opt_prompt, *opt_def_hint;
|
||||
gs_free char *def_hint = NULL;
|
||||
gs_free char *property_val = NULL;
|
||||
NMMetaPropertyInfFlags inf_flags;
|
||||
NMSetting *setting;
|
||||
|
||||
_meta_abstract_get(abstract_info,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&setting_name,
|
||||
&property_name,
|
||||
NULL,
|
||||
&inf_flags,
|
||||
&opt_prompt,
|
||||
&opt_def_hint);
|
||||
|
||||
if (!opt_def_hint) {
|
||||
setting = nm_connection_get_setting_by_name(connection, setting_name);
|
||||
if (setting)
|
||||
property_val = nmc_setting_get_property_parsable(setting, property_name, NULL);
|
||||
if (property_val)
|
||||
opt_def_hint = def_hint = g_strdup_printf("[%s]", property_val);
|
||||
}
|
||||
|
||||
prompt =
|
||||
g_strjoin("", gettext(opt_prompt), opt_def_hint ? " " : "", opt_def_hint ?: "", ": ", NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue