nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...
Fixes: 16902a2be6
This commit is contained in:
@@ -1713,13 +1713,13 @@ get_connection (NmCli *nmc, int *argc, char ***argv, int *pos, GError **error)
|
||||
|| strcmp (**argv, "uuid") == 0
|
||||
|| strcmp (**argv, "path") == 0) {
|
||||
selector = **argv;
|
||||
(*argc)--;
|
||||
(*argv)++;
|
||||
if (!*argc) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("%s argument is missing"), selector);
|
||||
return NULL;
|
||||
}
|
||||
(*argc)--;
|
||||
(*argv)++;
|
||||
}
|
||||
|
||||
connections = nm_client_get_connections (nmc->client);
|
||||
@@ -1760,13 +1760,13 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||
active_only = TRUE;
|
||||
next_arg (nmc, &argc, &argv);
|
||||
} else if (!order && nmc_arg_is_option (*argv, "order")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_set_error_literal (&err, NMCLI_ERROR, 0,
|
||||
_("'--order' argument is missing"));
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
/* TODO: complete --order */
|
||||
order = parse_preferred_connection_order (*argv, &err);
|
||||
if (err)
|
||||
@@ -1853,6 +1853,8 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
||||
|| strcmp (*argv, "path") == 0
|
||||
|| strcmp (*argv, "apath") == 0) {
|
||||
selector = *argv;
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
@@ -2593,37 +2595,37 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
||||
nmc_complete_strings (*argv, "ifname", "ap", "passwd-file", NULL);
|
||||
|
||||
if (strcmp (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
ifname = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_device (nmc->client, ifname, ap != NULL);
|
||||
}
|
||||
else if (strcmp (*argv, "ap") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
ap = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_bssid (nmc->client, ifname, ap);
|
||||
}
|
||||
else if (strcmp (*argv, "passwd-file") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc->return_value = NMC_RESULT_COMPLETE_FILE;
|
||||
|
||||
@@ -2789,13 +2791,13 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
|
||||
|| strcmp (*arg_ptr, "apath") == 0) {
|
||||
|
||||
selector = *arg_ptr;
|
||||
if (!argc) {
|
||||
arg_num--;
|
||||
arg_ptr++;
|
||||
if (!arg_num) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), selector);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
connections = nm_client_get_connections (nmc->client);
|
||||
@@ -4954,6 +4956,8 @@ read_properties:
|
||||
/* It would be better if "save" was a separate argument and not
|
||||
* mixed with properties, but there's not much we can do about it now. */
|
||||
g_clear_error (&error);
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text,
|
||||
_("Error: value for '%s' argument is required."),
|
||||
@@ -4961,8 +4965,6 @@ read_properties:
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (!nmc_string_to_bool (*argv, &save_bool, &error)) {
|
||||
g_string_printf (nmc->return_text, _("Error: 'save': %s."),
|
||||
error->message);
|
||||
@@ -8595,14 +8597,14 @@ do_connection_import (NmCli *nmc, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (strcmp (*argv, "type") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_vpn_service (*argv);
|
||||
|
||||
@@ -8612,13 +8614,13 @@ do_connection_import (NmCli *nmc, int argc, char **argv)
|
||||
g_printerr (_("Warning: 'type' already specified, ignoring extra one.\n"));
|
||||
|
||||
} else if (strcmp (*argv, "file") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc->return_value = NMC_RESULT_COMPLETE_FILE;
|
||||
if (!filename)
|
||||
|
@@ -2311,12 +2311,12 @@ do_device_set (NmCli *nmc, int argc, char **argv)
|
||||
nmc_complete_strings (*argv, "managed", "autoconnect", NULL);
|
||||
|
||||
if (matches (*argv, "managed")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_bool (*argv);
|
||||
if (!nmc_string_to_bool (*argv, &flag, &error)) {
|
||||
@@ -2328,12 +2328,12 @@ do_device_set (NmCli *nmc, int argc, char **argv)
|
||||
values[DEV_SET_MANAGED].value = flag;
|
||||
}
|
||||
else if (matches (*argv, "autoconnect")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_bool (*argv);
|
||||
if (!nmc_string_to_bool (*argv, &flag, &error)) {
|
||||
@@ -2634,22 +2634,22 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
||||
nmc_complete_strings (*argv, "ifname", "bssid", NULL);
|
||||
|
||||
if (strcmp (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
ifname = *argv;
|
||||
complete_device (devices, ifname, TRUE);
|
||||
} else if (strcmp (*argv, "bssid") == 0 || strcmp (*argv, "hwaddr") == 0) {
|
||||
/* hwaddr is deprecated and will be removed later */
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
bssid_user = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_aps (devices, NULL, bssid_user, NULL);
|
||||
@@ -2879,6 +2879,8 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (strcmp (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
@@ -2887,13 +2889,13 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
||||
ifname = *argv;
|
||||
complete_device (devices, ifname, TRUE);
|
||||
} else if (strcmp (*argv, "bssid") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
bssid = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_aps (devices, NULL, bssid, NULL);
|
||||
@@ -2905,22 +2907,22 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
||||
goto finish;
|
||||
}
|
||||
} else if (strcmp (*argv, "password") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
password = *argv;
|
||||
} else if (strcmp (*argv, "wep-key-type") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (*argv, "key", "phrase", NULL);
|
||||
if (strcmp (*argv, "key") == 0)
|
||||
@@ -2935,23 +2937,24 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
||||
goto finish;
|
||||
}
|
||||
} else if (strcmp (*argv, "name") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
con_name = *argv;
|
||||
} else if (strcmp (*argv, "private") == 0) {
|
||||
GError *err_tmp = NULL;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_bool (*argv);
|
||||
if (!nmc_string_to_bool (*argv, &private, &err_tmp)) {
|
||||
@@ -2962,13 +2965,14 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
||||
}
|
||||
} else if (strcmp (*argv, "hidden") == 0) {
|
||||
GError *err_tmp = NULL;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_bool (*argv);
|
||||
if (!nmc_string_to_bool (*argv, &hidden, &err_tmp)) {
|
||||
@@ -3339,42 +3343,42 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (strcmp (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
ifname = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_device (devices, ifname, TRUE);
|
||||
} else if (strcmp (*argv, "con-name") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
con_name = *argv;
|
||||
} else if (strcmp (*argv, "ssid") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
ssid = *argv;
|
||||
if (strlen (ssid) > 32) {
|
||||
g_string_printf (nmc->return_text, _("Error: ssid is too long."));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
} else if (strcmp (*argv, "band") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
band = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (band, "a", "bg", NULL);
|
||||
@@ -3384,20 +3388,20 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
} else if (strcmp (*argv, "channel") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
channel = *argv;
|
||||
} else if (strcmp (*argv, "password") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
password = *argv;
|
||||
/* --show-password is deprecated in favour of global --show-secrets option */
|
||||
/* Keep it here for backwards compatibility */
|
||||
@@ -3565,24 +3569,24 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv)
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
ifname = *argv;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_device (devices, ifname, TRUE);
|
||||
} else if (strcmp (*argv, "ssid") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
goto finish;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
g_ptr_array_add (ssids, *argv);
|
||||
} else if (!nmc->complete)
|
||||
g_printerr (_("Unknown parameter: %s\n"), *argv);
|
||||
@@ -3744,12 +3748,12 @@ do_device_lldp_list (NmCli *nmc, int argc, char **argv)
|
||||
nmc_complete_strings (*argv, "ifname", NULL);
|
||||
|
||||
if (strcmp (*argv, "ifname") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: %s argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
device = get_device (nmc, &argc, &argv, &error);
|
||||
if (!device) {
|
||||
|
@@ -655,24 +655,24 @@ do_general_logging (NmCli *nmc, int argc, char **argv)
|
||||
nmc_complete_strings (*argv, "level", "domains", NULL);
|
||||
|
||||
if (matches (*argv, "level")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete) {
|
||||
nmc_complete_strings_nocase (*argv, "TRACE", "DEBUG", "INFO", "WARN",
|
||||
"ERR", "OFF", "KEEP", NULL);
|
||||
}
|
||||
level = *argv;
|
||||
} else if (matches (*argv, "domains")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' argument is missing."), *(argv-1));
|
||||
return NMC_RESULT_ERROR_USER_INPUT;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete) {
|
||||
nmc_complete_strings_nocase (*argv, "PLATFORM", "RFKILL", "ETHER", "WIFI", "BT",
|
||||
"MB", "DHCP4", "DHCP6", "PPP", "WIFI_SCAN", "IP4",
|
||||
|
@@ -272,13 +272,13 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
||||
nmc->print_output = NMC_PRINT_PRETTY;
|
||||
} else if (matches (opt, "-mode")) {
|
||||
nmc->mode_specified = TRUE;
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "tabular", "multiline", NULL);
|
||||
if (matches (argv[0], "tabular"))
|
||||
@@ -291,13 +291,13 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
||||
return FALSE;
|
||||
}
|
||||
} else if (matches (opt, "-colors")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "yes", "no", "auto", NULL);
|
||||
if (matches (argv[0], "auto"))
|
||||
@@ -312,13 +312,13 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
||||
return FALSE;
|
||||
}
|
||||
} else if (matches (opt, "-escape")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
nmc_complete_strings (argv[0], "yes", "no", NULL);
|
||||
if (matches (argv[0], "yes"))
|
||||
@@ -331,24 +331,24 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
||||
return FALSE;
|
||||
}
|
||||
} else if (matches (opt, "-fields")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: fields for '%s' options are missing."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_fields (argv[0]);
|
||||
nmc->required_fields = g_strdup (argv[0]);
|
||||
} else if (matches (opt, "-get-values")) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: fields for '%s' options are missing."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 1 && nmc->complete)
|
||||
complete_fields (argv[0]);
|
||||
nmc->required_fields = g_strdup (argv[0]);
|
||||
@@ -362,13 +362,14 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
||||
/* ignore for backward compatibility */
|
||||
} else if (matches (opt, "-wait")) {
|
||||
unsigned long timeout;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (!argc) {
|
||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return FALSE;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (!nmc_string_to_uint (argv[0], TRUE, 0, G_MAXINT, &timeout)) {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not a valid timeout for '%s' option."),
|
||||
argv[0], opt);
|
||||
|
Reference in New Issue
Block a user