nmcli: don't print warning in nmcli connection import about duplicate parameters

It seems uncommon that a command line tool warns about duplicate
paramters. Usually, the latter just overwrites the former. That is also
useful so that you can have for example an alias that sets a default
type

  nmcli_import="nmcli connection import type keyfile"

but still call it like

  nmcli_import file $FILE type openvpn

This is a change in behavior. Not only stop we printing a warning, we
will now prefer the latter argument. Previously, the first was honored.
This change in behavior is a problem, but such uses were warned against
in the past, and hopefully nobody did this or relied on this.
This commit is contained in:
Thomas Haller 2022-09-30 10:00:48 +02:00
parent 394501e65a
commit 7adde3f2fc
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -9650,10 +9650,7 @@ do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
NULL);
}
if (!type)
type = *argv;
else
g_printerr(_("Warning: 'type' already specified, ignoring extra one.\n"));
type = *argv;
} else if (nm_streq(*argv, "file")) {
argc--;
@ -9665,10 +9662,8 @@ do_connection_import(const NMCCommand *cmd, NmCli *nmc, int argc, const char *co
}
if (argc == 1 && nmc->complete)
nmc->return_value = NMC_RESULT_COMPLETE_FILE;
if (!filename)
filename = *argv;
else
g_printerr(_("Warning: 'file' already specified, ignoring extra one.\n"));
filename = *argv;
} else {
g_string_printf(nmc->return_text, _("Error: invalid extra argument '%s'."), *argv);
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;