cli: multiline mode is default for 'dev list' and 'con list id|uuid'
Option '--multiline' was replaced with '--mode tabular|multiline'. It was neccessary to be able to switch to tabular output mode for 'dev list' and 'con list id|uuid' commands as they now print out in multiline mode by default. All other commands are in tabular mode by default.
This commit is contained in:
@@ -476,6 +476,8 @@ do_connections_list (NmCli *nmc, int argc, char **argv)
|
||||
return nmc->return_value;
|
||||
}
|
||||
valid_param_specified = TRUE;
|
||||
if (!nmc->mode_specified)
|
||||
nmc->multiline_output = TRUE; /* multiline mode is default for 'con list id|uuid' */
|
||||
|
||||
con1 = find_connection (nmc->system_connections, selector, *argv);
|
||||
con2 = find_connection (nmc->user_connections, selector, *argv);
|
||||
|
@@ -1164,6 +1164,8 @@ do_devices (NmCli *nmc, int argc, char **argv)
|
||||
nmc->return_value = do_devices_status (nmc, argc-1, argv+1);
|
||||
}
|
||||
else if (matches (*argv, "list") == 0) {
|
||||
if (!nmc->mode_specified)
|
||||
nmc->multiline_output = TRUE; /* multiline mode is default for 'dev list' */
|
||||
nmc->return_value = do_devices_list (nmc, argc-1, argv+1);
|
||||
}
|
||||
else if (matches (*argv, "disconnect") == 0) {
|
||||
|
@@ -66,7 +66,7 @@ usage (const char *prog_name)
|
||||
"OPTIONS\n"
|
||||
" -t[erse] terse output\n"
|
||||
" -p[retty] pretty output\n"
|
||||
" -m[ultiline] multiline output\n"
|
||||
" -m[ode] tabular|multiline output mode\n"
|
||||
" -f[ields] <field1,field2,...>|all|common specify fields to output\n"
|
||||
" -e[scape] yes|no escape columns separators in values\n"
|
||||
" -v[ersion] show program version\n"
|
||||
@@ -160,8 +160,23 @@ parse_command_line (NmCli *nmc, int argc, char **argv)
|
||||
}
|
||||
else
|
||||
nmc->print_output = NMC_PRINT_PRETTY;
|
||||
} else if (matches (opt, "-multiline") == 0) {
|
||||
} else if (matches (opt, "-mode") == 0) {
|
||||
nmc->mode_specified = TRUE;
|
||||
next_arg (&argc, &argv);
|
||||
if (argc <= 1) {
|
||||
g_string_printf (nmc->return_text, _("Error: missing argument for '%s' option."), opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return nmc->return_value;
|
||||
}
|
||||
if (!strcmp (argv[1], "tabular"))
|
||||
nmc->multiline_output = FALSE;
|
||||
else if (!strcmp (argv[1], "multiline"))
|
||||
nmc->multiline_output = TRUE;
|
||||
else {
|
||||
g_string_printf (nmc->return_text, _("Error: '%s' is not valid argument for '%s' option."), argv[1], opt);
|
||||
nmc->return_value = NMC_RESULT_ERROR_USER_INPUT;
|
||||
return nmc->return_value;
|
||||
}
|
||||
} else if (matches (opt, "-escape") == 0) {
|
||||
next_arg (&argc, &argv);
|
||||
if (argc <= 1) {
|
||||
@@ -269,6 +284,7 @@ nmc_init (NmCli *nmc)
|
||||
nmc->should_wait = FALSE;
|
||||
nmc->print_output = NMC_PRINT_NORMAL;
|
||||
nmc->multiline_output = FALSE;
|
||||
nmc->mode_specified = FALSE;
|
||||
nmc->escape_values = TRUE;
|
||||
nmc->required_fields = NULL;
|
||||
nmc->allowed_fields = NULL;
|
||||
|
@@ -104,6 +104,7 @@ typedef struct _NmCli {
|
||||
gboolean should_wait; /* Indication that nmcli should not end yet */
|
||||
NMCPrintOutput print_output; /* Output mode */
|
||||
gboolean multiline_output; /* Multiline output instead of default tabular */
|
||||
gboolean mode_specified; /* Whether tabular/multiline mode was specified via '--mode' option */
|
||||
gboolean escape_values; /* Whether to escape ':' and '\' in terse tabular mode */
|
||||
char *required_fields; /* Required fields in output: '--fields' option */
|
||||
NmcOutputField *allowed_fields; /* Array of allowed fields for particular commands */
|
||||
|
Reference in New Issue
Block a user