-
Notifications
You must be signed in to change notification settings - Fork 117
[feat] Add auto completion support to ReFrame #1685
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
Conversation
|
So far this is a bit of a poc. On Daint this can be tested with Currently, this supports completion of command line options: files and directories for and test names given a directory or file through the |
Codecov Report
@@ Coverage Diff @@
## master #1685 +/- ##
=======================================
Coverage 87.33% 87.34%
=======================================
Files 46 46
Lines 7740 7742 +2
=======================================
+ Hits 6760 6762 +2
Misses 980 980
Continue to review full report at Codecov.
|
vkarak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just played a bit with this PR. These are some problems I've noticed:
- Strange characters when auto-completing command-line options:
$ reframe --c
--checkpath^[[m^[[K --config-file^[[m^[[K--cpu-only^[[m^[[K
- The same happens when it auto-completes the command-line:
$ reframe --checkpath^[\[m^[\[K
|
@vkarak in which terminal did you try? |
|
@rsarm I tried on my Mac's bash. But then I started playing with #!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
import argcomplete
from argcomplete.completers import EnvironCompleter
import reframe.frontend.argparse as argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--env-var1").completer = EnvironCompleter
parser.add_argument("--env-var2").completer = EnvironCompleter
parser.add_argument("--env-var3").completer = EnvironCompleter
options = parser.parse_args()
if __name__ == '__main__':
main()And I added the following two lines in our @@ -257,6 +257,9 @@ class ArgumentParser(_ArgumentHolder):
`add_argument()` call. If no default value was specified either, the
attribute will be set to `None`.'''
+ import argcomplete
+ argcomplete.autocomplete(self._holder)
+
# We always pass an empty namespace to our internal argparser and we do
# the namespace resolution ourselves. We do this, because we want the
# newly parsed options to completely override any options defined inNow if I try to run |
vkarak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This PR adds command-line auto-completion to ReFrame through the argcomplete package. It also adds some automatically generated shell script code that users will need to source in order to enable auto-completion for their shells.
Closes #725