-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add bash_completion #308
Add bash_completion #308
Conversation
Should I also update the README.md to include instructions on how to install the bash completion? |
Thank you very much for the pull request!! Yes, please, feel free to mention bash completion in README.md! I will take a look at the patch soon! |
Codecov Report
@@ Coverage Diff @@
## master #308 +/- ##
=======================================
Coverage 95.72% 95.72%
=======================================
Files 12 12
Lines 3673 3673
=======================================
Hits 3516 3516
Misses 157 157
Continue to review full report at Codecov.
|
Thanks @pablocostass for this nice PR! One comment/concern I have with it though is whether we can find a way to avoid duplication of the list of options that the |
Good point Kostis!
Personally, I don't care much about the duplication if we can add some test
for keeping the two consistent. I think the options suite in tests real
might have inspiration, but I need to check more carefully.
… |
A valid concern @kostis, I can see having to update the file for each option added or modified a bit tedious. Do you have any suggestions on how to avoid duplicating the list of options? If you ask me, I think as @aronisstav. Most of the options don't have their own data type (which would imply adding more keywords to autocomplete), so adding or removing one is changing two/three lines at most. I'm no master at testing bash scripts, but if you need an extra pair of hands to do them I can give it a try. |
I've started looking into writing some test. While I am struggling to understand how complete works, perhaps someone can enlighten me on how to make it return e.g. a list of all the short or long option names. |
Found this, still working on it: https://stackoverflow.com/questions/3520936/accessing-bash-completions-for-specific-commands-programmatically |
What I know of bash completion is thanks to this guide and from looking at rebar3 and kerl's completion. If you are thinking of adding CI testing of/with the bash completion, kerl has a nice config file for both CircleCI and Travis. In short, you are going to need to know of three variables:
And so, you will normally return a completion based on the previous word (COMP_WORDS[COMP_CWORD-1]) and the current one (COMP_WORDS[COMP_CWORD]). That completion is generated through the use of compgen and its different options (e.g., to return a word list you would do |
More questions:
Alternatively:
|
Oopsie, I'm sorry. Misread the files and thought they were using the completion feature.
https://github.com/scop/bash-completion/blob/master/bash_completion#L339-L365
I'm by no means a regex expert but I could try making one to only get the long options from the file, but (pardon me if I did not understand you correctly) why would you want a script that returns the list of long options from the autocomplete file to make your own one when you can get them all from the |
Thank you for the link, I'll check it in a while. For the other question, "consumes" was uneccessary poetic :-p I'd like to use some invocation of the actual commands, either by sourcing the script and calling some appropriate version of the _concuerror function and inspecting the relevant variable or something similar. |
I am back on this today, let's see what I can achieve... :-) Update 1: Update 2: Update 3: |
b53b196
to
1f8e859
Compare
So, I added a few tests for some obvious scenarios and even caught a bug in the listing of long options. I also added a line in the CHANGELOG. @pablocostass please take a look and let me know if you would like to add any other tests! |
@aronisstav Hey, this is really great! I think those tests are more than enough. Thanks a lot for doing them, as they are very instructive and they will for sure be my reference if I ever need to test bash completion of Erlang programs again 😄 |
Other than the two (very minor) comments above, this looks good and can be merged. |
95b80a8
to
e7bec38
Compare
e7bec38
to
2ce532d
Compare
Summary
Adds a bash_completion file for Concuerror with the options from
concuerror_options.erl
as per requested in #159.Checklist