Skip to content
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

Search Command Improvements #5254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

theduke
Copy link

@theduke theduke commented Sep 15, 2021

  • adds a --skip-description flag for not searching in package descriptions
  • adds a --plain flag for plain output that only prints a line with the package path for each match

src/nix/search.cc Outdated Show resolved Hide resolved
Adds a new `--skip-description` flag to the `nix search` command.

This flag will exclude package description from the search.
Adds a new `--plain` flag to the search command.
If present, only a single line with the package path will be printed for
each match, without any terminal decorations.
@edolstra
Copy link
Member

I'm not sure --plain is all that useful since you can do the same thing using --json, e.g.

# nix search --json | jq -r 'keys[]'

What's the intended use case for --plain?

The name --skip-description is a bit ambiguous since it's not clear whether it skips searching or printing the description.

@theduke
Copy link
Author

theduke commented Sep 15, 2021

The name --skip-description is a bit ambiguous since it's not clear whether it skips searching or printing the description.

Yeah, I wasn't sure about the name. I started with --name-only / -n, but it's rare to not want to search in the path as well, imo.
So I'm happy for other suggestions.

I'm not sure --plain is all that useful

This is a very common need for me.
I often want to either quickly narrow down available pacakges, or just find the name of one I forgot, and the default output is too verbose for that.
It's also useful for piping the results into some other tool or writing it to a file.

Remembering the json structure each time and adding the |jq pipe ends up as a pretty annoying extra step.
A shell alias could of course fix that for me, but only on personal systems, not on servers.

I think it's useful enough to include.

@stale
Copy link

stale bot commented Apr 16, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Apr 16, 2022
@fricklerhandwerk fricklerhandwerk added the UX The way in which users interact with Nix. Higher level than UI. label Sep 9, 2022
@abathur
Copy link
Member

abathur commented Nov 2, 2022

Some potential flag names:

  • --exclude-description or --ignore-description
  • --exclude-field <name|path|description|...> or --ignore-field <name|path|description|...>
  • --exclude-fields [<name|path|description|...>,...] or --ignore-fields [<name|path|description|...>,...]
  • might be tedious, but a clearer name and more explicit behavior: --search-fields [<name|path|description|...>,...]

@stale stale bot removed the stale label Nov 2, 2022
@arcuru
Copy link
Contributor

arcuru commented Nov 3, 2022

  1. I will echo the idea that --plain would be a useful flag, and that the nix search --json | jq pipe is not a reasonable alternative. I think the UX gain of the flag will probably be worth the maintenance burden.
  2. I think that generalizing the "ignore" piece of this would be a good idea, as @abathur suggested.

To maintainers, maybe you'd like this PR to be split?

@stale stale bot added the stale label May 21, 2023
@Ericson2314 Ericson2314 added the new-cli Relating to the "nix" command label Jun 22, 2023
@stale stale bot removed the stale label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-cli Relating to the "nix" command UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants