-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Overhaul completions, redo #6693 #8131
Overhaul completions, redo #6693 #8131
Conversation
Regressions:
Basically we only get tilde expansion for |
@ncfavier Thanks. Let's try to get those in the test prior to merging this PR I think.
Thanks, that should be an easy enough fix.
Oh hmm I didn't think it looked that way, but I'll think about this. |
8d67683
to
3698a4b
Compare
@ncfavier Hmm I am confused. I added tests based on what you said, but I didn't see any regressions. |
3698a4b
to
b62158c
Compare
OK, now it is fixed :). Thanks again, @ncfavier, those tests proved quiete helpful in catching both places that needed to change. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-03-31-nix-team-meeting-minutes-45/27002/1 |
b62158c
to
7b3bc26
Compare
7b3bc26
to
3f5bb41
Compare
3f5bb41
to
ff86438
Compare
ff86438
to
8213b6c
Compare
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.
Reviewed with @tomberek.
Overall the change is good, but it needs a bit of clarification for us mortals who don't dream in C++ (yet).
Would be great to have the new docstrings as a separate commit for easier bisection.
00cb006
to
6a5403e
Compare
6a5403e
to
5cb0fd9
Compare
As I complained in NixOS#6784 (comment) (a comment on the wrong PR, sorry again!), NixOS#6693 introduced a second completions mechanism to fix a bug. Having two completion mechanisms isn't so nice. As @thufschmitt also pointed out, it was a bummer to go from `FlakeRef` to `std::string` when collecting flake refs. Now it is `FlakeRefs` again. The underlying issue that sought to work around was that completion of arguments not at the end can still benefit from the information from latter arguments. To fix this better, we rip out that change and simply defer all completion processing until after all the (regular, already-complete) arguments have been passed. In addition, I noticed the original completion logic used some global variables. I do not like global variables, because even if they save lines of code, they also obfuscate the architecture of the code. I got rid of them moved them to a new `RootArgs` class, which now has `parseCmdline` instead of `Args`. The idea is that we have many argument parsers from subcommands and what-not, but only one root args that owns the other per actual parsing invocation. The state that was global is now part of the root args instead. This did, admittedly, add a bunch of new code. And I do feel bad about that. So I went and added a lot of API docs to try to at least make the current state of things clear to the next person. -- This is needed for RFC 134 (tracking issue NixOS#7868). It was very hard to modularize `Installable` parsing when there were two completion arguments. I wouldn't go as far as to say it is *easy* now, but at least it is less hard (and the completions test finally passed). Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
5cb0fd9
to
d121326
Compare
I'd need to review it again in full as it seems to have changed quite a bit, and I'm not sure I'll find enough time for it in the next week given other priorities. But my clarification requests were addressed in code comments, so I'm almost at peace with this change. @tomberek could you take it over the finish line? |
Sounds good
I don't think I changed it a lot? Mean thing is I landed the tests and API docs for existing stuff first. The rest should be more or less the same (just small things in response to review comments). At least I don't remember doing anything big! |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-10-16-nix-team-meeting-minutes-95/34396/1 |
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.
Okay, now that I got the quiet to look at it properly, this looks very good. The doc comments help a lot with following the code, and the updated names don't stick out any more.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-10-23-nix-team-meeting-minutes-97/34561/1 |
As I complained in NixOS#6784 (comment) (a comment on the wrong PR, sorry again!), NixOS#6693 introduced a second completions mechanism to fix a bug. Having two completion mechanisms isn't so nice. As @thufschmitt also pointed out, it was a bummer to go from `FlakeRef` to `std::string` when collecting flake refs. Now it is `FlakeRefs` again. The underlying issue that sought to work around was that completion of arguments not at the end can still benefit from the information from latter arguments. To fix this better, we rip out that change and simply defer all completion processing until after all the (regular, already-complete) arguments have been passed. In addition, I noticed the original completion logic used some global variables. I do not like global variables, because even if they save lines of code, they also obfuscate the architecture of the code. I got rid of them moved them to a new `RootArgs` class, which now has `parseCmdline` instead of `Args`. The idea is that we have many argument parsers from subcommands and what-not, but only one root args that owns the other per actual parsing invocation. The state that was global is now part of the root args instead. This did, admittedly, add a bunch of new code. And I do feel bad about that. So I went and added a lot of API docs to try to at least make the current state of things clear to the next person. -- This is needed for RFC 134 (tracking issue NixOS#7868). It was very hard to modularize `Installable` parsing when there were two completion arguments. I wouldn't go as far as to say it is *easy* now, but at least it is less hard (and the completions test finally passed). Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Change-Id: If18cd5be78da4a70635e3fdcac6326dbfeea71a5 (cherry picked from commit 67eb37c1d0de28160cd25376e51d1ec1b1c8305b)
Motivation
As I complained in
#6784 (comment) (a comment on the wrong PR, sorry again!), #6693 introduced a second completions mechanism to fix a bug. Having two completion mechanisms isn't so nice.
As @thufschmitt also pointed out, it was a bummer to go from
FlakeRef
tostd::string
when collecting flake refs. Now it isFlakeRefs
again.The underlying issue that sought to work around was that completion of arguments not at the end can still benefit from the information from latter arguments.
To fix this better, we rip out that change and simply defer all completion processing until after all the (regular, already-complete) arguments have been passed.
In addition, I noticed the original completion logic used some global variables. I do not like global variables, because even if they save lines of code, they also obfuscate the architecture of the code.
I got rid of them moved them to a new
RootArgs
class, which now hasparseCmdline
instead ofArgs
. The idea is that we have many argument parsers from subcommands and what-not, but only one root args that owns the other per actual parsing invocation. The state that was global is now part of the root args instead.This did, admittedly, add a bunch of new code. And I do feel bad about that. So I went and added a lot of API docs to try to at least make the current state of things clear to the next person.
Context
This is needed for RFC 134 (tracking issue #7868). It was very hard to modularize
Installable
parsing when there were two completion arguments. I wouldn't go as far as to say it is easy now, but at least it is less hard (and the completions test finally passed).Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.sh
src/*/tests
tests/nixos/*
Priorities
Add 👍 to pull requests you find important.