GNOME Bugzilla – Bug 738613
[RFE] sort connections and add TERM colors to output of nmcli
Last modified: 2015-02-25 13:49:25 UTC
For example, the output of `nmcli connection show` could be colored, with active connections shown as green, activating connections yellow, and inactive connections as white.
I have implemented sorting of the connections. The sorting can be influenced by --order option. The color support has been added to nmcli output as well, coloring not only connection list, but also devices, general status, radio switches, etc. The code is available in jk/nmcli-sort-colors branch.
Looks good overall, a few small nits. > nmcli: sort connections in 'nmcli con show' output + for (i = 0; i < sizeof(default_order)/sizeof(NmcSortOrder); i++) { G_N_ELEMENTS(default_order) ? > nmcli: add --order option for 'nmcli connection show' + int num = sizeof (def) / sizeof(NmcSortOrder); G_N_ELEMENTS() ? > nmcli: add support for terminal formatting, like bold, dim, undreline, etc. undreline -> underline
Fixed items from comment #2. I have also made minor changes in man page and fixed '--colors' option name. The branch is rebased to master.
If my comments are fixed, ACK from me.
Merged to master as: afe086e merge: nmcli: sort connections and add colors to nmcli output (bgo #738613) 126bc15 nmcli: colorize 'general', 'radio' and 'networking' outputs 4668f20 nmcli: show devices list in colors a80a1b6 nmcli: show connection list in colors 758e488 nmcli: add global '--colors' option for controlling color output bc265d4 nmcli: add support for terminal formatting, like bold, dim, underline, etc. b77ec93 nmcli: add support for printing color strings 4e0e61f nmcli: pay attention to color escape sequencies when counting string length 3e8fc26 nmcli: make filtering color sequences a utility function 40e98f5 nmcli: add --order option for 'nmcli connection show' b4d5296 nmcli: sort connections in 'nmcli connection show' output 8f60081 nmcli: (trivial): use real parameter types in fill_output_connection() prototype
Created attachment 297697 [details] [review] WIP: cli/completion: add completion for --order option Does not yet work... the colon is treated special, I don't know how to fix it ATM. https://bugzilla.gnome.org/show_bug.cgi?id=738613 Fixes: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f
(In reply to Thomas Haller from comment #6) > Created attachment 297697 [details] [review] [review] > WIP: cli/completion: add completion for --order option > > Does not yet work... the colon is treated special, I don't know how to > fix it ATM. > > https://bugzilla.gnome.org/show_bug.cgi?id=738613 > > Fixes: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f bash completion is missing... the --order is tricky due to the colon. First shot is here (but doesn't work). Also, I think the warning "Error: 'type' repeats in '--order' option." is pretty severe towards the user. I think we should just silently accept it.
(In reply to Thomas Haller from comment #7) > (In reply to Thomas Haller from comment #6) > > Created attachment 297697 [details] [review] [review] [review] > > WIP: cli/completion: add completion for --order option > > > > Does not yet work... the colon is treated special, I don't know how to > > fix it ATM. > > > > https://bugzilla.gnome.org/show_bug.cgi?id=738613 > > > > Fixes: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f > > bash completion is missing... the --order is tricky due to the colon. First > shot is here (but doesn't work). > Let's put that to a new bug and track it there. > > Also, I think the warning "Error: 'type' repeats in '--order' option." is > pretty severe towards the user. I think we should just silently accept it. Actually, this was intentional. But if you prefer, only warn and continue: jk/nmcli-order-warn
(In reply to Jiri Klimes from comment #8) > (In reply to Thomas Haller from comment #7) > > Also, I think the warning "Error: 'type' repeats in '--order' option." is > > pretty severe towards the user. I think we should just silently accept it. > > Actually, this was intentional. > But if you prefer, only warn and continue: jk/nmcli-order-warn LGTM, but I would ignore it silently. Don't think that printing a warning is helpful in this case.
(In reply to Thomas Haller from comment #9) > (In reply to Jiri Klimes from comment #8) > > (In reply to Thomas Haller from comment #7) > > > Also, I think the warning "Error: 'type' repeats in '--order' option." is > > > pretty severe towards the user. I think we should just silently accept it. > > > > Actually, this was intentional. > > But if you prefer, only warn and continue: jk/nmcli-order-warn > > LGTM, but I would ignore it silently. Don't think that printing a warning is > helpful in this case. Hmm, I prefer user passing "valid" strings to nmcli. Thus I prefer showing the warning message so that user can correct the command. But let's get another opinion on this.
(In reply to Jiri Klimes from comment #8) > (In reply to Thomas Haller from comment #7) > > (In reply to Thomas Haller from comment #6) > > > Created attachment 297697 [details] [review] [review] [review] [review] > > > WIP: cli/completion: add completion for --order option > > > > > > Does not yet work... the colon is treated special, I don't know how to > > > fix it ATM. > > > > > > https://bugzilla.gnome.org/show_bug.cgi?id=738613 > > > > > > Fixes: 40e98f5d685bc41da32f65e6ee3b5ad1b46cca3f > > > > bash completion is missing... the --order is tricky due to the colon. First > > shot is here (but doesn't work). > > > > Let's put that to a new bug and track it there. > https://bugzilla.gnome.org/show_bug.cgi?id=745157 > > > > Also, I think the warning "Error: 'type' repeats in '--order' option." is > > pretty severe towards the user. I think we should just silently accept it. > > Actually, this was intentional. > But if you prefer, only warn and continue: jk/nmcli-order-warn (In reply to Jiri Klimes from comment #10) > (In reply to Thomas Haller from comment #9) > > (In reply to Jiri Klimes from comment #8) > > > (In reply to Thomas Haller from comment #7) > > > > Also, I think the warning "Error: 'type' repeats in '--order' option." is > > > > pretty severe towards the user. I think we should just silently accept it. > > > > > > Actually, this was intentional. > > > But if you prefer, only warn and continue: jk/nmcli-order-warn > > > > LGTM, but I would ignore it silently. Don't think that printing a warning is > > helpful in this case. > > Hmm, I prefer user passing "valid" strings to nmcli. Thus I prefer showing > the warning message so that user can correct the command. But let's get > another opinion on this. After discussing with lrintel, I decided to remove the warning. 8b35b9e cli: silently ignore duplicated categories in "--order" option (bgo #738613)