-
Notifications
You must be signed in to change notification settings - Fork 198
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
TAB completion crashes on unknown commands if followed by parameters #3815
Comments
This goes not just for parameters but also sub commands, e.g. |
I think it should simply not try to complete (it's bad to print out things while completing I think) |
I just ran into this while playing with the aiida environment for the workshop next week. I think this might be especially confusing to beginners who might more easily mistake the I'd be happy to fix this next week. I agree that the correct course of action is to do nothing in this case.
|
Hmm, this is tricky. The File "/opt/conda/bin/verdi", line 8, in <module>
sys.exit(verdi())
File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1254, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1297, in resolve_command
cmd = self.get_command(ctx, cmd_name) It seems that these two code paths need different behavior (cannot call |
Thanks @danielhollas for the additional info. How do you trigger the two different path ways? I can only get pathway of the OP. |
This would be an option but I am pretty sure that we would get messages from users saying that tab-completion is broken and it turns out they just had an invalid subcommand in their chain. E.g. when doing:
and it just won't complete anything, but it is easy to overlook the type in the subcommand
Seeing the stack trace may scare users and think something is wrong with AiiDA, whereas the error clearly shows what went wrong and they can correct their command. |
@sphuber the first pathway is triggered if you enter an invalid command and hit enter, e.g. $ verdi st Note that in this case aiida prints an error message without the stacktrace, as it should (I have printed the stack trace manually via
While I agree with this in principle, even without stack trace this is still a surprising behavior for Linux users. I am not aware of any Linux command that would behave like this. In fact, when tab completion is not working, I am (personally) immediately triggered to verify my command is correct. |
Note that per the issue below, most of the tab completion functionality is now natively supported by click (and it's not clear whether the |
@sphuber I agree with @danielhollas that I would not show an error - I never saw a command showing an error on tab completion. If you e.g. try with git (and have proper completion enabled), @danielhollas thanks! Also pinging @csadorf who's our dependency manager for his feedback. |
I'm fine with either solution really. I don't think it is a bug in Regarding As for your point on interactive commands @giovannipizzi , such as |
Actually, the solution is going to be a bit more tricky. If we want to keep the current behavior of suggesting close commands in the case a non-existing command is specified, we cannot get rid of that conditional. We just have to disable it when |
My comment was about what to take into account if we bump to the next major version of click. I think what I had in mind is this: aiida-core/aiida/cmdline/params/options/interactive.py Lines 21 to 46 in a2ddbd5
Our class redefines a lot of the internal click methods of the super class, and (IIRC from when I was looking and working on it, probably 2-3 years ago) it changes the "logic" of "when/under which situation" those methods are called, to add interactiveness in the way we wanted. I think the tests we have should catch possible issues, but it would be good to double check explicitly those interactive commands when we upgrade the click version. (Ideally, it would be great to contribute that class back to click so we're not responsible anymore for maintaining it, but I don't know if they are intested and willing to take it. If anybody has time to look into it and possibly make a PR to them, it would be great - we would also learn if what we do is the "right" way of doing it, and maybe they now have something equivalent?) |
Thanks @sphuber @giovannipizzi ! 🍻 |
If I write
verdi ru count_query.py
and I press TAB I get on screenI think this is triggering some buggy path and this is because there is a parameter after the wrong/incomplete command
ru
(instead tab completion works if I press tab directly afterverdi ru
)The text was updated successfully, but these errors were encountered: