Merge pull request #6695 from afishhh/search-fix-exclude

Fix arity of `--exclude` flag in `nix search`
This commit is contained in:
Eelco Dolstra 2022-06-21 16:12:04 +02:00 committed by GitHub
commit bbe7187db9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -34,7 +34,9 @@ struct CmdSearch : InstallableCommand, MixJSON
.shortName = 'e', .shortName = 'e',
.description = "Hide packages whose attribute path, name or description contain *regex*.", .description = "Hide packages whose attribute path, name or description contain *regex*.",
.labels = {"regex"}, .labels = {"regex"},
.handler = Handler(&excludeRes), .handler = {[this](std::string s) {
excludeRes.push_back(s);
}},
}); });
} }

View file

@ -43,3 +43,4 @@ e=$'\x1b' # grep doesn't support \e, \033 or even \x1b
(( $(nix search -f search.nix foo --exclude 'foo|bar' | grep -Ec 'foo|bar') == 0 )) (( $(nix search -f search.nix foo --exclude 'foo|bar' | grep -Ec 'foo|bar') == 0 ))
(( $(nix search -f search.nix foo -e foo --exclude bar | grep -Ec 'foo|bar') == 0 )) (( $(nix search -f search.nix foo -e foo --exclude bar | grep -Ec 'foo|bar') == 0 ))
[[ $(nix search -f search.nix -e bar --json | jq -c 'keys') == '["foo","hello"]' ]]