Bug 1351263

Summary: [review] lr/cli-ask-rh1351263: [RFE] allow passing -a to the end of nmcli command
Product: Red Hat Enterprise Linux 7 Reporter: Vladimir Benes <vbenes>
Component: NetworkManagerAssignee: Lubomir Rintel <lrintel>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: atragler, bgalvani, blueowl, fgiudici, lkundrak, lrintel, mleitner, rkhan, sukulkar, thaller
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: NetworkManager-1.8.0-0.4.rc1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 09:17:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1393481    

Description Vladimir Benes 2016-06-29 14:44:17 UTC
Description of problem:
as stated here: https://bugzilla.redhat.com/show_bug.cgi?id=1141947#add_comment
it would be nice to allow --ask parameter (and maybe others) to be entered at the end as if you don't have some credentials you have to go all the way back to add -a.

Version-Release number of selected component (if applicable):
1.2

Comment 1 Thomas Haller 2016-07-05 14:34:19 UTC
note that for convenience, nmcli supports all kind of abbreviations for options and arguments. Allowing options in every order makes parsing more complicated (maybe) and possibly more ambiguous.

But sounds like a good thing to me.


For now, assigning to Lubomir as he did the recent nmcli rework :)

Comment 2 Blueowl 2016-12-06 09:56:11 UTC
Although accepting options (--ask here) at the end might seem handy first, it would be at the cost of unnecessary complexity and ambiguity. And I think KISS principle should be kept here.

--ask can be added with command-line (bash) editing shortcuts very simply :)
Just pressing two shortcuts:

Home Alt-F
or
Ctrl-A Alt-F

and then adding "-a" option.

A few useful links:
* http://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/
* http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/
* https://wiki.archlinux.org/index.php/Keyboard_shortcuts
* http://superuser.com/questions/344308/bash-jump-to-first-argument

Comment 3 Lubomir Rintel 2017-03-24 14:02:34 UTC
I believe it makes sense to process --ask anywhere. It also simplifies things a bit, since the concept of a global option concept removes the need for special casing of --show-secrets option.

https://cgit.freedesktop.org/NetworkManager/NetworkManager/log/?h=lr/cli-ask-rh1351263

Comment 4 Francesco Giudici 2017-03-25 11:26:01 UTC
In process_command_line() there is now a redundant completion for --ask --show-secret: pushed a fixup on top of the branch for that.

top commit msg:
cli/connections: drop the redundant parsinG of --show-secrets
(G is missing)



Now the --ask and --show-secrets options are auto-completed everywhere.
A couple of examples:
1) "nmcli" auto-completes main commands and just "--ask" and "--show-secrets" options only (before options were just suggested if "-" was found)
2) "nmcli conn show" auto-completes "--ask". Uglier, when autocompleted in "nmcli conn show uuid".

Not sure is good having --ask and --show-secrets auto-completing everywhere.
I think it is fine to have them enabled at any point in the command, but would be better to have more control on where they pop out in auto-completion.

rest lgtm

Comment 5 Lubomir Rintel 2017-03-27 13:17:51 UTC
(In reply to Francesco Giudici from comment #4)
> In process_command_line() there is now a redundant completion for --ask
> --show-secret: pushed a fixup on top of the branch for that.
> 
> top commit msg:
> cli/connections: drop the redundant parsinG of --show-secrets
> (G is missing)

Fixed.

> Now the --ask and --show-secrets options are auto-completed everywhere.
> A couple of examples:
> 1) "nmcli" auto-completes main commands and just "--ask" and
> "--show-secrets" options only (before options were just suggested if "-" was
> found)
> 2) "nmcli conn show" auto-completes "--ask". Uglier, when autocompleted in
> "nmcli conn show uuid".
> 
> Not sure is good having --ask and --show-secrets auto-completing everywhere.
> I think it is fine to have them enabled at any point in the command, but
> would be better to have more control on where they pop out in
> auto-completion.

Good catch. I restored the behaviour where it completes when "-" is already seen. I think that in that case it makes sense to restore it in all cases where it's actually allowed.

> rest lgtm

Fixed up the first commit not to parse the global options when a value is expected. (e.g. so that nmcli c add con-name --ask would not change behavior)

Pushed an updated branch

Comment 6 Francesco Giudici 2017-03-28 07:32:39 UTC
lgtm

Comment 7 Beniamino Galvani 2017-03-28 12:03:20 UTC
Minor issue:

 nmcli connection show wired --show-secrets

does not show secrets. Otherwise looks good.

Comment 8 Lubomir Rintel 2017-03-28 13:59:36 UTC
(In reply to Beniamino Galvani from comment #7)
> Minor issue:
> 
>  nmcli connection show wired --show-secrets
> 
> does not show secrets. Otherwise looks good.

Yes, that is because the option is only read after the connection is processed. Will try to improve this in future.

Merged as-is in fa292a60aa180101ff7192f5c0dd52231ea37356

Comment 10 errata-xmlrpc 2017-08-01 09:17:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2299