After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 738613 - [RFE] sort connections and add TERM colors to output of nmcli
[RFE] sort connections and add TERM colors to output of nmcli
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nmcli
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-10-16 09:14 UTC by Thomas Haller
Modified: 2015-02-25 13:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WIP: cli/completion: add completion for --order option (3.68 KB, patch)
2015-02-23 18:03 UTC, Thomas Haller
none Details | Review

Description Thomas Haller 2014-10-16 09:14:11 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.
Comment 1 Jiri Klimes 2015-02-17 12:47:33 UTC
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.
Comment 2 Dan Williams 2015-02-17 23:17:00 UTC
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
Comment 3 Jiri Klimes 2015-02-19 11:00:38 UTC
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.
Comment 4 Dan Williams 2015-02-20 22:53:02 UTC
If my comments are fixed, ACK from me.
Comment 5 Jiri Klimes 2015-02-23 08:42:56 UTC
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
Comment 6 Thomas Haller 2015-02-23 18:03:21 UTC
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
Comment 7 Thomas Haller 2015-02-23 18:05:32 UTC
(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.
Comment 8 Jiri Klimes 2015-02-24 12:47:42 UTC
(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
Comment 9 Thomas Haller 2015-02-24 13:10:34 UTC
(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.
Comment 10 Jiri Klimes 2015-02-24 14:32:53 UTC
(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.
Comment 11 Jiri Klimes 2015-02-25 13:49:25 UTC
(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)