lix/src/libcmd
John Ericson 3d065192c0 Overhaul completions, redo #6693 (#8131)
As I complained in
https://github.com/NixOS/nix/pull/6784#issuecomment-1421777030 (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`
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 #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)
2024-03-25 15:30:36 +00:00
..
built-path.cc Merge pull request #9582 from pennae/misc-opts 2024-03-04 07:32:31 +01:00
built-path.hh Allow dynamic derivation deps in inputDrvs 2023-09-07 10:39:37 -04:00
command-installable-value.cc Finish converting existing comments for internal API docs (#8146) 2023-04-07 13:55:28 +00:00
command-installable-value.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
command.cc Merge pull request #9289 from edolstra/fix-warnings 2024-03-04 05:27:35 +01:00
command.hh Overhaul completions, redo #6693 (#8131) 2024-03-25 15:30:36 +00:00
common-eval-args.cc Overhaul completions, redo #6693 (#8131) 2024-03-25 15:30:36 +00:00
common-eval-args.hh Clean up SearchPath 2023-07-09 23:22:22 -04:00
editor-for.cc Merge pull request #9634 from 9999years/combine-abstract-pos-and-pos 2024-03-05 23:46:18 -07:00
editor-for.hh Merge pull request #9634 from 9999years/combine-abstract-pos-and-pos 2024-03-05 23:46:18 -07:00
installable-attr-path.cc Fixing #7479 2023-08-18 11:44:00 -04:00
installable-attr-path.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
installable-derived-path.cc Fixing #7479 2023-08-18 11:44:00 -04:00
installable-derived-path.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
installable-flake.cc feat: notation to refer to no attribute search prefix 2024-03-25 15:30:36 +00:00
installable-flake.hh Rename 'resolvedRef' to 'lockedRef' 2023-07-03 12:23:57 +02:00
installable-value.cc Merge pull request #9634 from 9999years/combine-abstract-pos-and-pos 2024-03-05 23:46:18 -07:00
installable-value.hh Make more string values work as installables 2023-05-15 09:03:38 -04:00
installables.cc Overhaul completions, redo #6693 (#8131) 2024-03-25 15:30:36 +00:00
installables.hh Merge pull request #9648 from cole-h/nix-shell-ordering 2024-03-04 07:50:55 +01:00
legacy.cc Move command plugin interface to libnixcmd 2021-01-26 06:22:24 -05:00
legacy.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
local.mk Merge pull request #9465 from obsidiansystems/build-dir 2024-03-04 07:11:25 +01:00
markdown.cc do not render relative links in help pages 2022-08-26 17:10:41 +02:00
markdown.hh Ensure all headers have #pragma once and are in API docs 2023-03-31 23:19:44 -04:00
meson.build build: optionally build and install with meson 2024-03-22 08:36:50 -06:00
nix-cmd.pc.in Fix building with GCC 9 2023-02-10 18:38:57 +01:00
repl-interacter.cc add automated usage mode to the repl 2024-03-11 14:14:43 -07:00
repl-interacter.hh add automated usage mode to the repl 2024-03-11 14:14:43 -07:00
repl.cc Revert "Merge pull request #9476 from alois31/restore-progress-bar" 2024-03-23 18:04:29 -07:00
repl.hh refactor: move readline stuff into its own file 2024-03-11 01:04:52 -07:00