Skip to content

Commit

Permalink
improve search
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBen committed Oct 27, 2024
1 parent 884bba4 commit 79d850b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions rush
Original file line number Diff line number Diff line change
Expand Up @@ -1773,17 +1773,17 @@ rush_search_command() {
prefix=''
[[ "$repo" != "default" ]] && prefix="$repo:"

blue "Matching packages:\n"
find "$repo_path" -type d |
grep -v "$repo_path.*/\." |
grep --color=always "$text" |
sed "s#${repo_path}/#${prefix}#g"
bold "Matching packages ($repo):\n"
find "$repo_path" -type f -name main |
sed "s#${repo_path}/#${prefix}#g; s#/main##" |
grep --color=always --ignore-case "$text" |
sort

blue "\nMatching info files:\n"
bold "\nMatching info files ($repo):\n"
grep --color=always --initial-tab --recursive --ignore-case --include "info" \
"$text" "$repo_path" |
sort |
sed "s#${repo_path}/#${prefix}#g" | sed 's#/info##'
sed "s#${repo_path}/#${prefix}#g; s#/info##" |
sort

echo
}
Expand Down
16 changes: 8 additions & 8 deletions src/search_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ search_repo() {
[[ "$repo" != "default" ]] && prefix="$repo:"

## Search directories matching search text
blue "Matching packages:\n"
find "$repo_path" -type d |
grep -v "$repo_path.*/\." |
grep --color=always "$text" |
sed "s#${repo_path}/#${prefix}#g"
bold "Matching packages ($repo):\n"
find "$repo_path" -type f -name main |
sed "s#${repo_path}/#${prefix}#g; s#/main##" |
grep --color=always --ignore-case "$text" |
sort

## Search info files matching search text
blue "\nMatching info files:\n"
bold "\nMatching info files ($repo):\n"
grep --color=always --initial-tab --recursive --ignore-case --include "info" \
"$text" "$repo_path" |
sort |
sed "s#${repo_path}/#${prefix}#g" | sed 's#/info##'
sed "s#${repo_path}/#${prefix}#g; s#/info##" |
sort

echo
}
Expand Down
12 changes: 6 additions & 6 deletions test/approvals/rush_search_hello
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Matching packages:
Matching packages (default):

hello

Matching info files:

Matching info files (default):

hello: $ rush info hello

Matching packages:
Matching packages (sample):

sample:hello

Matching info files:

Matching info files (sample):

sample:hello: $ rush info hello
12 changes: 6 additions & 6 deletions test/approvals/rush_search_running
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Matching packages:
Matching packages (default):


Matching info files:

Matching info files (default):

hello: This info file can be accessed by running
nested/hi: This info file can be accessed by running

Matching packages:
Matching packages (sample):


Matching info files:

Matching info files (sample):

sample:hello: This info file can be accessed by running
sample:nested/hi: This info file can be accessed by running

0 comments on commit 79d850b

Please sign in to comment.