-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define the cmd line options into groups for the help output #672
Comments
The following is a first attempt, just to establish that this works (I removed all but the first line of each help description). I know this is not correct but it is a starting point for discussion DISCUSSION What are logical groups and what items should be in each group?
|
NOTE: This code works by adding two new decorators:
It does not directly offer dependency functionality (allow --user only if --server is defined) and we really do not want that since we must consider not only the options on the command line but the use of general options in interactive mode. |
Since there is now a library that allows defining groups of options, this PR defines the groups for the command line options. WIP: Currently the tests have not been modified and this is just a first proposal to determine if the library works.
We agreed that we will:
|
Since there is now a library that allows defining groups of options, this PR defines the groups for the command line options. WIP: Currently the tests have not been modified and this is just a first proposal to determine if the library works.
Since there is now a library that allows defining groups of options, this PR defines the groups for the command line options. WIP: Currently the tests have not been modified and this is just a first proposal to determine if the library works.
Since there is now a library that allows defining groups of options, this PR defines the groups for the command line options. WIP: Currently the tests have not been modified and this is just a first proposal to determine if the library works.
Since there is now a library that allows defining groups of options, this PR defines the groups for the command line options. WIP: Currently the tests have not been modified and this is just a first proposal to determine if the library works.
I overlooked the fact that this click contribution only supports python 3.6 and above, at least partly because its setup.py uses pathlib package which only supports python 3.6 and above. Writing pr to see if we can get them to expand support to match click. Filed issue click-contrib/click-option-group#18 on click-option-group. Next step is to create a pr with proposed fix but that takes longer. |
The author is willing to consider providing compatibility back to python 3.5 or maybe 3.4 if someone else does the work but clearly stated that he will not consider compatibility with python 2.7. At this point the initial problem with python 3.5 is the use of the use of PathLib in the setup.py. We have not explored further. I note also that the author later pretty much said he is not interested in python 3.5 compatibility, contermanding his earlier interest if I did the conversion. |
There is another much more limited stand-alone library that would provide the segregation of options into groups but it is not part of the click-contrib https://github.com/janLuke/cloup/blob/master/cloup/_cloup.py which accomplishes grouping but no semantic control (exclusions, etc.) Note that there is also a very old issue in click that discussed both of the current public implementations : pallets/click#373 |
Since the click-option-group package only supports Python 3.6 and above, we would either have to spend the effort to backport the function to Python 3.4 and 3.5, and we would not get it into Python 2.7. I don't think this functionality is worth it to drop support for Python 2.7, or to spend the effort to backport it to Python 3.4 and 3.5. As a result, the only option seems to be to defer this functionality until we drop these versions for other reasons. |
There is one alternative, a very simple proposal that would gain the grouping of the top level group but not the other features such as choice exclusion. |
After a review of the code in click_ tontrib option groups it is vclear that it is comppletly committed to python 3.6 + since it include all of the type hinting that started with that version. It is a clean model in that it uses decorators for both the group and grouped option definitions:
Doing the grouping with decorators creates a complex set of code for what should be a simple problem. Some alternate syntax's (see click issue https://github.com/pallets/click/blob/master/src/click/core.py) might be something simpler like:
or
or even
because in general they avoid the new decorator on the inner option definitions and depend on either explicit user of the cls option or on python grouping to group options within a group. |
We had discussed grouping command line options earlier in the development process sot that they were organized within groups in the help display. However, click did not offer that capability (Note: that this exists in argparse). About 6 months ago a new click contrib (click-group-options) was added to the click contrib project and that package now appears to be stable so the capability to group the command line argumetns exists for us.
This click contrib library works by installing the click-option-group package and causes no other internal changes to pywbemcli beyond changing he decorartors on the option definitions to break them into groups.
The issue for us is what is a logical set of groupings that aids our users.
The text was updated successfully, but these errors were encountered: